M1: doc-level free list, sessions, and a spec runner that no longer overstates #1

Merged
dev merged 37 commits from m1-cursors into main 2026-08-09 16:15:34 +00:00
Showing only changes of commit 343b25adc8 - Show all commits

View File

@@ -1890,6 +1890,20 @@ pub const Engine = struct {
if (self.compacting.swap(true, .acq_rel)) return;
defer self.compacting.store(false, .release);
// Reclamation first, because it is the cheap half of the same job: a
// checkpoint hands back whole windows for the cost of one publish,
// where a rebuild copies every live byte in the database. Whatever it
// takes, the per-collection gate below no longer sees, so a collection
// whose garbage was all in empty windows is not rewritten at all.
//
// This is not a refinement, it is what makes reclamation reachable
// under a delete-heavy workload. A checkpoint is otherwise armed by log
// volume, and a delete logs only an `_id` -- so deleting half a 190 MB
// collection moves the log by a couple of megabytes and no checkpoint
// runs, while the garbage sails past the rebuild threshold. Measured
// with the churn harness: six rounds, six rebuilds, 1 MB reclaimed.
try self.checkpoint();
try self.catalog_lock.lockShared(self.io);
var rebuild_err: ?anyerror = null;
var db_it = self.dbs.iterator();