perf: apply DELETE tombstones at COMMIT for transactional deletes (no flush rewrite) - #368
Merged
Merged
Conversation
… 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.
|
This was referenced Sep 3, 2026
MPCoreDeveloper
changed the base branch from
perf/tombstone-delete
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/tombstone-delete(PR perf: durable Columnar DELETE in-place via tombstone markers (no flush rewrite) #367 — in-place durable DELETE via tombstone markers).Waarom
Stap-0-profiling (env-gestuurde op/flush-splitsing +
Database.Flush-fasebreakdown) toonde:ExecuteBatchSQLdraait elke batch in een storage-transactie, dus batch-DELETE nam de rollback-veilige deferral (_pendingLogicalDeletes) endb.Flush()deed nog steeds de full-fileCompactPendingDeletes-rewrite (~0,5–0,7 s; DELETE ~12–16K ops/s). Tombstones werden in de benchmark dus nooit geschreven.Fix
IStorage.BufferTombstoneForCommit(default no-op) + Storage-implementatie: buffert per bestand de fysieke offsets van in-transactie-deletes.ApplyBufferedTombstones()draait inFlushBufferedAppendsAndOverwrites()(de commit-path) ná de buffered appends op schijf staan → markers in-place, O(delete), geen rewrite. Offsets van rijen die in dezelfde transactie zijn geïnsereerd én verwijderd zijn dan geldig.ClearBufferedAppends) gooit de buffer weg → rij blijft behouden.DeleteRecordsCore+ de contiguous FW-bulk-path bufferen de offsets i.p.v._pendingLogicalDeleteste verhogen → flush-compactie is volledig van het batch-DELETE-pad af.Metingen (zelfde machine, Release, 10K deletes op ~100K rijen)
--pklegacy--pkfixed-widthValidatie
BatchDelete_CommitTimeTombstones_SurviveReopenWithoutExplicitFlush— deletes overleven reopen zonder explicieteFlushnaExecuteBatchSQL.SharpCoreDB.Tests(Debug + Release/CI-filter) en de CI-suites (VectorSearch, EFCore, Linq2DB): EXIT=0.