Repository navigation
feat: add owner-coordinated database compaction - #238
Closed
vinceblock99 wants to merge 1 commit into
Closed
vinceblock99 wants to merge 1 commit into
vinceblock99 wants to merge 1 commit into
Conversation
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.
Repeated writes can leave reclaimable space in the combined
atomic.redb. Addatomic compact [--repository PATH] [--json]to let users explicitly reclaim that space through the existing database owner. The command reports the absolute database path, before/after file sizes, and reclaimed bytes.This follows the database-size investigation: on a copy of a 66-file repository, explicit compaction reduced the file from 19,664,896 to 14,307,328 bytes, reclaiming 5,357,568 bytes (27.2%) while preserving its data. redb already reuses freed pages and can shrink on ordinary commits; explicit compaction can reclaim additional space by reorganizing pages. This PR addresses that measured opportunity without changing the graph/index representation or deleting change objects.
Compaction requires exclusive access, so it is an explicit owner operation rather than maintenance on every command or shutdown:
ATOMIC_DB_LOCK_WAIT_MS, then a clear error if still busy. Once started, compaction runs to completion.pub(super)), avoiding a new public Repository opening API. The CLI sends an IPC request; the owner remains available afterward.Graph, views, provenance,
.changefiles, and unrecorded working files are preserved. This command only operates on an existingatomic.redb: it does not create tables/databases, migrate legacy layouts, delete persistent savepoints, or run automatically. Large repositories should be compacted during a quiet period because other database operations may exhaust their lock-wait budgets while compaction runs.This Draft PR is stacked on #230 and targets
feat/atomic-redb, so its diff contains only compaction and its tests/documentation. Retarget todevafter #230 lands. This PR does not modifyatomic-storage.Validation on macOS:
cargo test --workspace --locked --offline: 9,125 passed, 0 failed, 243 ignored, including all 28 owner integration tests.cargo clippy --workspace --locked --offline -- -D warnings,cargo fmt --all -- --check, and the CI semantic diff harness (23/23 assertions) passed. Linux and Windows verification is left to CI.