perf(sqlite-native): remove delete file existence probe#4631
Conversation
PR Review: perf(sqlite-native): remove delete file existence probeThe optimization is sound. Removing the kv_get existence probe before kv_delete_range saves one KV round-trip per delete in the common case where a file exists. Since kv_delete_range is a no-op on an empty range, the probe was redundant. The change is correct and safe. Issue: WASM VFS parity not maintainedCLAUDE.md requires the native Rust VFS and WASM TypeScript VFS to match 1:1, including delete/truncate strategy. The WASM counterpart (rivetkit-typescript/packages/sqlite-vfs/src/vfs.ts) still performs the existence probe before deleting (lines 1395-1413): The same optimization should be applied to the WASM VFS in this PR to keep the two implementations in sync. Right now they diverge: the native Rust VFS unconditionally deletes, while the WASM VFS probes first and short-circuits. This could lead to subtly different observable behavior, for example different error propagation when the meta key is absent but chunk keys exist from a partial write. Minor: extra KV round-trip when file never existedWhen the file does not exist, the new code issues two KV ops (range delete + meta delete) instead of the one probe the old code issued. This is unlikely to matter in practice since SQLite xDelete is normally only called on existing files, but it is a slight regression for that edge case. SummaryThe optimization is valid and the code is correct. The main concern is the divergence from the WASM VFS. packages/sqlite-vfs/src/vfs.ts should be updated to match (remove the get probe, always issue deleteRange + deleteBatch) to satisfy the CLAUDE.md 1:1 parity requirement. |
87e4122 to
8c30d87
Compare
a60a42d to
9d72e25
Compare
8c30d87 to
86fec2b
Compare
2bb44ed to
bf17632
Compare
86fec2b to
79dfb24
Compare
79dfb24 to
b3ff6d3
Compare
bf17632 to
93e8897
Compare

Description
Please include a summary of the changes and the related issue. Please also include relevant motivation and context.
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes.
Checklist: