Skip to content

Commit b6a447c

Browse files
committed
Compress transactional ZoneTree disk segments with LZ4
Validated with a strict Debug solution build, 14 focused functional cases, 15 process-kill cases and a local one-million-event load across three real replicas.
1 parent 783e890 commit b6a447c

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

‎docs/Features/StorageRecovery.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ REQ-STORAGE-HOST-COMPOSITION-001 / AC-STORAGE-HOST-COMPOSITION-001: PartitionDat
1919
KeyLoad owns no write-ahead log, snapshot or archive format; storage and its redo log are ZoneTree's ([ADR-011](../ADR/ADR-011-current-format.md)). A store directory holds `owner.lock`, `identity.json` and the ZoneTree MVCC tree under `tree/`.
2020

2121
- **Native redo logs.** ZoneTree owns WAL and recovery for both physical trees. `ZoneTreeTreeFactory` selects uncompressed `Shared` WAL for MVCC and `SyncCompressed` for direct resource data.
22+
- **Transactional disk segments.** ZoneTree writes MVCC disk segments with `LZ4Fastest`. Native backup restore uses the same disk-segment settings. Compaction can hold original and replacement segments concurrently, so capacity planning uses peak disk use during writes.
2223
- **One transaction per commit.** `ZoneTreeStoreCommitExecution` compiles against a native snapshot and uses ZoneTree's serializable conflict handling; `ZoneTreeCommitPublication` stages one ZoneTree MVCC transaction that holds the staged mutations and the store position record under `system/position`. A commit with no mutations publishes nothing and keeps the position. `Store.Position` is read back from the tree on open. ZoneTree replays its own log when it opens and drops a transaction whose commit never reached the log.
2324
- **Direct resources.** A nontransactional resource publishes its direct native writes before its transactional outcome. Its multi-record effects do not acquire transactional atomicity.
2425
- **Process-persistent publication.** ZoneTree 2.1.1's caller-side WAL paths hold each completed write before it returns. A returned atomic commit and its outcome survive process termination. The storage service and all coordinators acknowledge after that publication, without requesting a disk sync for each command or batch. ZoneTree owns periodic disk sync and MVCC commit-state retirement. `IAtomicStore.SyncAsync` remains an explicit disk barrier; disposing the store joins native work and flushes its log.

‎src/KeyLoad.Storage.ZoneTree/StorageEngine/Execution/ZoneTreeTreeFactory.cs‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ internal static ZoneTreeFactory<StorageKey, StorageValue> Storage(string directo
5858
o.MutableSegmentBloomFilterBitsPerItem = 0;
5959
})
6060
.ConfigureWriteAheadLogOptions(ConfigureWriteAheadLog)
61-
.ConfigureDiskSegmentOptions(o => o.CompressionMethod = CompressionMethod.None);
61+
.ConfigureDiskSegmentOptions(ConfigureTransactionalDiskSegment);
6262

6363
private static ZoneTreeFactory<Memory<byte>, Memory<byte>> Create(string directory)
6464
=> new ZoneTreeFactory<Memory<byte>, Memory<byte>>()
@@ -72,7 +72,13 @@ private static ZoneTreeFactory<Memory<byte>, Memory<byte>> Create(string directo
7272
// The transactional tree's native AutoSyncInterval syncs its complete WAL and commit state.
7373
options.SyncCompressedModeOptions.EnableTailWriterJob = false;
7474
})
75-
.ConfigureDiskSegmentOptions(o => o.CompressionMethod = CompressionMethod.None);
75+
.ConfigureDiskSegmentOptions(ConfigureTransactionalDiskSegment);
76+
77+
private static void ConfigureTransactionalDiskSegment(DiskSegmentOptions options)
78+
{
79+
options.CompressionMethod = CompressionMethod.LZ4;
80+
options.CompressionLevel = CompressionLevels.LZ4Fastest;
81+
}
7682

7783
// SyncCompressed synchronously publishes records into the native mapped WAL tail before returning.
7884
// This is the ProcessDurable acknowledgement boundary; disk sync remains engine-owned background work.

0 commit comments

Comments
 (0)