perf: batch tombstone writes (C4) + structured batch DELETE (B3) - #369
Merged
Conversation
added 3 commits
September 3, 2026 20:18
… flush rewrite) Stap-0 profiling showed batch DELETE (ExecuteBatchSQL wraps every batch in a storage transaction) was NOT using the tombstone path: the rollback-safe deferral only counted _pendingLogicalDeletes, so db.Flush() still ran the #366 full-file CompactPendingDeletes rewrite (~0.5-0.7s; DELETE stuck at ~12-16K ops/s). - IStorage.BufferTombstoneForCommit (default no-op) + Storage implementation: buffered offsets per file, applied as in-place negative-prefix markers by ApplyBufferedTombstones() inside FlushBufferedAppendsAndOverwrites() (the commit path) AFTER buffered appends are on disk; rollback discards the buffer via ClearBufferedAppends(). - DeleteRecordsCore + the contiguous FW bulk path now buffer the deleted offsets when IsInTransaction instead of incrementing _pendingLogicalDeletes, so the flush-time full-file rewrite is off the batch-DELETE path entirely. - Regression: batch DELETE survives reopen even WITHOUT an explicit Flush after ExecuteBatchSQL (commit already tombstoned the rows). Measured (same machine, Release, comparative harness DELETE 10K of ~100K rows): SQL 0.82s/12K -> 0.24s/41K ops/s, Direct 0.63s/16K -> 0.17s/58K ops/s; --pk legacy 0.16s/62K, fixed-width 0.13s/78K ops/s. Full suite EXIT=0.
- IStorage.TombstoneRecords (default loops TombstoneRecord); Storage batches the in-place negative-prefix markers over one cached read handle and evicts each affected page-cache page once instead of once per row. - ApplyBufferedTombstones (commit path) and Table.TombstoneDeletedPositions (direct non-transactional deletes) route through the batch API; offsets that are not physical records (EOF/already-marked) are skipped safely.
…parse (B3) - TryParseDeleteForBatch now also returns the canonical WHERE column + raw literal; ExecuteBatchSQL groups (where, column, literal) instead of plain WHERE strings. - Table.DeleteMultipleKeys mirrors DeleteMultiple (contiguous-FW gate -> PK fast path -> hash fast path -> generic fallback) but resolves keys directly from the pre-parsed column/literal; the 'col = literal' string and the second TryParseSimpleWhereClause pass are built only when a generic fallback actually runs. - Non-canonical statements keep the string path (mixed tables rebuild on the rare path).
|
This was referenced Sep 3, 2026
MPCoreDeveloper
changed the base branch from
perf/commit-time-tombstones
to
master
September 3, 2026 19:35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Stack
perf/commit-time-tombstones(PR perf: apply DELETE tombstones at COMMIT for transactional deletes (no flush rewrite) #368) ← baseperf/tombstone-delete(PR perf: durable Columnar DELETE in-place via tombstone markers (no flush rewrite) #367) ← master.Inhoud (twee commits)
C4 —
a862757abatch-tombstones met evict-dedupIStorage.TombstoneRecords(path, offsets)(default = per-offsetTombstoneRecord); Storage-implementatie schrijft de negatieve-prefix-markers over één gecachete read-handle en evict per page één keer i.p.v. per rij.ApplyBufferedTombstones) als de directe non-transactionele deletes (Table.TombstoneDeletedPositions) lopen via de batch-API; offsets die geen fysiek record zijn (EOF / al gemarkeerd) worden veilig overgeslagen.B3 —
78d21ea1structured batch-DELETE (geen dubbele parse)TryParseDeleteForBatchretourneert ook de canonieke WHERE-column + ruwe literal;ExecuteBatchSQLgroepeert(where, column, literal).Table.DeleteMultipleKeysspiegelDeleteMultiple(contiguous-FW-gate → PK-fast-path → hash-fast-path → generieke fallback) maar resolve keys direct uit de voorgeparste waarden; decol = literal-string en de tweedeTryParseSimpleWhereClauseworden alleen gebouwd als een generieke fallback écht nodig is.Meting (Release, 10K deletes op ~100K rijen; median van 3 runs)
--pklegacy / fixed-widthConclusie: functioneel neutraal binnen run-ruis (±10%). De wijzigingen zijn veilig (full suite groen) en verminderen allocaties (B3) en page-cache-evicts + handle-gebruik (C4) — pas bij grotere tabellen/allocatie-gevoelige workloads zichtbaar. De volgende echte hefboom blijft B1 (key-only deletes zonder per-rij
engine.Read+ volledige rij-deserialisatie).Validatie
SharpCoreDB.Testsfull suite (Debug) + Release/CI-filter op alle vier de suites (incl. VectorSearch/EFCore/Linq2DB): EXIT=0.