Skip to main content

Module policy

Module policy 

Source
Expand description

Size caps and the compaction trigger. Size caps and the compaction trigger.

Pure arithmetic over byte counts, deliberately free of engine and storage types so the thresholds can be tested and reasoned about on their own. Every constant here is derived from measurements recorded in the data layer design record, not chosen by feel.

Enums§

SizeVerdict
Where a compacted document sits against the cap.

Constants§

COMPACT_DELTA_LOG_RATIO
Compact once the delta log is this many times the compacted document.
COMPACT_MAX_COMMITS
Compact after this many commits regardless of byte ratios, 1024.
COMPACT_MIN_DELTA_LOG_BYTES
Floor under the compaction trigger, 64 KiB.
DOC_SIZE_WARN_BYTES
Size at which a document starts warning, 768 KiB (75% of the cap).
MAX_DOC_BYTES
Hard cap on the compacted encoding of one document, 1 MiB.

Functions§

needs_size_check
Whether the document is close enough to the warning threshold that its true compacted size has to be measured before the next commit is accepted.
should_compact
Whether a document should be rewritten as a fresh compacted snapshot.
size_verdict
Classify a compacted document size.