Compacted Epoch Parameters and Dense Pair-Stream Packing #
This module defines the 8-word persistent root header, the 225-word active epoch header, the
metadata-first compacted epoch layout, and the dense [0, n) (quotient, value) pair-stream
packing for the resizable succinct dynamic dictionary of Bender, Farach-Colton, J. Kuszmaul and
W. Kuszmaul, SOSA 2024.
Memory layout ([metaBase, +offCompItems) and [itemBase, +compactedItemWords)) #
- Persistent 8-word root header (
[metaBase, metaBase + 8)):[U - 1, V - 1, w, keyBits U, valBits V, N, n, n_init](storingU - 1andV - 1soV = 2 ^ wfits in aw-bit word). Whenn = 0(N = 0), the resting dictionary occupies only these8words (compactedEpochWords U V w 0 0 = 8). - Active epoch parameter and hash-scratch header (
[metaBase + 8, metaBase + 225)):[metaBase + 8, metaBase + 27): 19 words ofRuntimeReducedKWise.HashParams.[metaBase + 27, metaBase + 63): 36 words ofCompParams.[metaBase + 63, metaBase + 225): 162-word limb scratch (RuntimeReducedKWise.scratchWords).
- Epoch metadata prefix (
[metaBase + 225, metaBase + offCompItems U w N)):Hash(Succinct.hashSpace U w N),LocalMeta(9 * Succinct.lmSubWords N w),GlobalMeta,TailToDense, andDenseToTail. - Dense
[0, n)item stream ([itemBase, itemBase + compactedItemWords U V w N n)):nactive(quotient, value)pairs packed densely at global bit offsetsd * (quotientBits U N + valBits V)andd * (quotientBits U N + valBits V) + quotientBits U N. ParameterizingitemBaseseparately frommetaBaseallows both resting in-epoch states (itemBase = metaBase + offCompItems U w N) and single-tape epoch migration (Zone 1 metadata + Zone 3 shared item arena) to share the exact sameMemory.Progoperations.
Main definitions #
Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.rootHdrWords,RootHeaderValid,EpochValid,targetCap: root header and epoch capacity invariants.Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.wOffQ,bOffQ,wOffV,bOffV,compactedItemWords,compQuotAt,compValAt,writeCompQuot,writeCompVal: overflow-free dense[0, n)pair-stream packing.Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.epochHdrWords,offCompLM,offCompLMSub,offCompGM,offTailToDense,offDenseToTail,offCompItems,compactedEpochWords: compacted epoch word offsets and total footprint.Cslib.DataStructure.Dictionary.WordRAM.ResizableSuccinct.CompParams,mkCompParams,EpochParamsStored: 36-word runtime parameter block and header storage predicate.
Main results #
compactedItemWords_succ_sub_le_two: adding one item growscompactedItemWordsby≤ 2words.quotientBits_le_add_six_of_le_four_mul,succinctWords_mul_w_le_bits: quotient-bit and word-to-bit space conversion helpers.
References #
Section 1: Dense [0, n) Pair-Stream Bit Packing #
Overflow-free word offset of the quotient field q_d at dense index d in a stream of
(q_bits, v_bits) pairs on a w-bit machine.
Intra-word bit offset < w of the quotient field q_d at dense index d.
Overflow-free word offset of the value field v_d at dense index d.
Intra-word bit offset < w of the value field v_d at dense index d.
Word footprint of n densely packed (quotient, value) entries in epoch N.
Adding 1 live item increases compactedItemWords by at most 2 words when U, V ≤ 2 ^ w.
Section 2: Persistent Root Header, Compacted Epoch Layout, and 1 · OPT Space Bounds #
The 8-word persistent root header [U - 1, V - 1, w, keyBits U, valBits V, N, n, n_init].
Word offset 8 of the 19-word RuntimeReducedKWise.HashParams vector.
Word offset 27 of the 36-word CompParams vector.
Word offset 63 of the 162-word limb scratch slice (63 + 162 = 225).
Word offset 225 where the active epoch's ReducedKWise hash table and seed begin.
Persistent 8-word root header invariant at metaBase.
- fits_U : WordRAM.Fits w U
- pos_U : 0 < U
- pos_V : 0 < V
Epoch capacity invariant: N = 0 when n = 0, else 1 ≤ n ≤ N ≤ 4 * n ∧ N ≤ U.
A valid epoch bounds its size by its capacity, and its capacity by four times the size and by the universe size. These inequalities force zero capacity for an empty epoch.
Target epoch capacity min (2 * n) U (0 when n = 0).
The target capacity of a nonempty epoch fits the universe and is at most twice its size.
Effective quotient bit-width max (quotientBits U N) 1 (= Succinct.qBits U N).
Reduction target bit-width totalMicroBits N + 1 (= Succinct.hashB N).
Word footprint of the epoch quotient hash (= Succinct.hashSpace U w N).
Word offset of LocalMeta relative to metaBase in a compacted epoch of capacity N.
Word offset of the c-th LocalMeta sub-array (c < 9) relative to metaBase.
Word offset of GlobalMeta relative to metaBase in a compacted epoch of capacity N.
Word offset of TailToDense relative to metaBase.
Word offset of DenseToTail relative to metaBase.
Word offset of the dense [0, n) active (quotient, value) stream relative to metaBase.
The compacted item stream starts after the fixed epoch header and scratch region.
Total resting word footprint of a compacted epoch (N, n):
8 words when n = 0 (rootHdrWords), and offCompItems U w N + compactedItemWords U V w N n
when 0 < n.
Section 3: Pure Metadata Extractors and Runtime CompParams #
Runtime 36-word parameter vector stored at [metaBase + offCompParams, +36).
Instances For
Populate the 36-word CompParams vector for (U, V, w, N).
Word width $w$.
Capacity parameter $N$.
Capacity minus one, $N - 1$.
Quotient bit width $q$.
Value bit width $v$.
Local metadata subtable offset for coordinate $c < 9$.
Local metadata entry bit-length.
Global metadata table offset.
Global metadata entry bit-length.
Tail-to-dense permutation offset.
Dense-to-tail permutation offset.
Maximum tail item capacity.
Number of bucket bits $\lceil \log_2 N \rceil$.
Bitmask for bucket bits $2^{\mathrm{bucketBits}} - 1$.
Bucket slab size parameter $K$.
Slab size minus one $K - 1$.
Twice slab size $2K$.
Direct slab count.
Direct slab count minus one.
Tail capacity parameter.
Global metadata slab directory base index.
Global metadata tail pointer base index.
Global metadata tail owner base index.
Global metadata slab metadata base index.
Micro-block count.
Minimum capacity bound.
Item array offset.
Hash family workspace allocation words.
Stored runtime parameter blocks in [metaBase + 8, metaBase + 63) for active epoch N.
- hp_eq (i : Fin 19) : mem (metaBase + offHashParams + ↑i) = HashFamily.WordRAM.RuntimeReducedKWise.mkHashParams w (epochQBits U N) (epochHashB N) (SuccinctBucket.totalMicroBits N) 3 i