Repository navigation
Description
DEFAULT_REINDEX_MIN_BYTES is 100 bytes (fluree-db-api/src/server_defaults.rs:31). Any commit's novelty exceeds that, so the default is effectively "build an index after every commit." That was deliberate — 8ad4f65ab ("Update default index min-bytes to 100", 2026-06-29) lowered it from 100_000 and documented the intent in place:
// 100 bytes — effectively reindex after every commit (any commit's novelty
// exceeds this), so the persisted index tracks the head with minimal lag.
pub const DEFAULT_REINDEX_MIN_BYTES: usize = 100;The same commit reworded the config template from "100 KB — triggers background reindexing" to "bytes of novelty before a background reindex (default ≈ every commit)".
This issue asks whether that trade is right for write-heavy workloads, now that #1548 has given us field evidence about what a build-per-commit costs.
Why now
#1548 reported a single-node file-storage deployment where sustained small commits produced heavy index-artifact churn. Two figures from that report, as measured by the reporter:
- ~4,100 commits / ~1.2M flakes over ~1h with
FLUREE_REINDEX_MIN_BYTES=2000000produced 3.0 GB on disk for 52 MB of commit data, including ~2,400 dictionary artifacts and 216 index roots. - On 4.1.2 defaults, ~370 small captures produced 25 GB across 34k files.
The reporter explicitly noted results were worse at the 100-byte default, and asked for the default to get a second look even after the leak was fixed.
The reclamation work on #1548 bounds the accumulation — superseded artifacts are now reachable and collectable, and a storage sweep reclaims what was already orphaned. It does not change the churn: at one build per commit, the write and CPU cost of producing those artifacts is unchanged, they are simply cleaned up afterward. Reclaiming 25 GB is better than leaking it, but not writing it is better still.
What to evaluate
-
Per-build cost as a function of ledger size. Forward dict packs are incremental (
build_incremental_string_packsemits only entries above the watermark), but the reverse-tree update and root re-publish happen on every build. Measure bytes written per build against ledger size to find out whether per-commit indexing is O(delta) or has an O(ledger) component. File storage: superseded index snapshots/dictionaries are never reclaimed in practice, and POST /reindex permanently breaks the GC chain (root published with no garbage manifest) #1548 asserts the latter for dictionaries; that claim has not been verified in isolation and should be, since it decides whether this is a tuning question or a scaling one. -
The freshness the default buys. The stated rationale is minimal index lag. Quantify what lag actually costs — queries over unindexed novelty go through the overlay path, so the trade is query latency on recent data against write amplification. Without that number the default cannot be argued either way.
-
Whether one default can serve both shapes. A read-heavy ledger with occasional writes and a sustained-ingest ledger want opposite settings. Options worth comparing: raise the static default, scale it from ledger size, or add a time-based floor so bursts coalesce into one build.
Suggested outcome
Either a defended default (with the measurements recorded, so the next person doesn't re-litigate it) or a changed one. If it changes, docs/operations/configuration.md and the config template in server_defaults.rs both carry the value and need updating together — 8ad4f65ab touched both.
Related
- File storage: superseded index snapshots/dictionaries are never reclaimed in practice, and POST /reindex permanently breaks the GC chain (root published with no garbage manifest) #1548 — index artifacts never reclaimed; this default is listed there as an aggravating factor rather than the cause
8ad4f65ab— the commit that set the current value
Activity
bplatz commentedon Sep 16, 2026
Field data point for the "per-build cost as a function of ledger size" question, from the deployment that also produced #1862.
_systemledger, single branch, file storage: 5,584 index builds over 3 days at the 100-byte default. Decoding one publish's garbage manifest (t=57620) gave:So roughly 31 MB of index-artifact churn per build against a ledger whose live index and commit log were both far smaller. At 5,584 builds that's the dominant cost, not the freshness this default buys — and #1862 only reclaims that churn after the fact, it doesn't reduce it. Filing as a data point rather than a recommendation, since freshness cost (item 2 above) is unmeasured here.
aaj3f commentedon Sep 16, 2026
Answering item 1 of "What to evaluate" directly, since we measured it while looking at something else — and the answer is a third option that isn't on the list.
Per-build cost is neither O(delta) nor O(ledger). It is O(1) in ledger size with a large constant. A ladder of ledgers, each given one small insert and then an incremental
fluree index, measured twice independently:Neither pass shows any growth across a 700× range of ledger size. Two runs at different machine loads agreeing on that is the part I would rest the conclusion on.
The spread between the passes is worth having in front of you rather than tidied away, because it is what makes "flat" a meaningful word here. It shows run-to-run noise on a shared box at around ±3 s — the 1 k point is first in its sequence and carries cold-cache and first-touch effects, so I would not read the ordering within either pass as signal. That noise is the scale against which "no growth" should be read: an O(ledger) term across a 700× range would be enormous and could not hide inside a band this size, so its absence is not an artifact of measurement resolution.
On the absolutes: roughly 5 s is a good working figure, single-machine, and load was not recorded for the first pass, so I would not present it as a certified floor to two decimal places. The flatness is the finding; the constant is approximate.
And it extends further down than the ladder goes. A colleague chasing an unrelated annotation defect ran the smallest control that exists — a single-triple ledger — and its incremental build still cost tens of seconds on a loaded box, the same regime as ledgers a million times larger measured under comparable load. I am deliberately not putting that number next to the 5 s ladder above, because it came off a different machine and the two are not commensurable; what it establishes is the direction, which is the part that matters here: the toll does not shrink as the ledger shrinks. A ledger with one triple in it pays it.
So for this issue's purposes: the 100-byte default means every commit pays the same fixed overhead no matter how little changed, and that overhead does not shrink as the ledger shrinks. That seems to me to strengthen the case for raising the default rather than weaken it — the cost is not amortized against anything.
This is the time-and-blocking half of the same per-build cost @bplatz measured in bytes above. ~31 MB of artifact churn per build and a fixed multi-second wall-clock toll are the same phenomenon seen through two instruments.
The shape of the cost, since it constrains the fix
It is blocking/syscall-bound, not compute and not paging. On a 68 s run (
/usr/bin/time -l):usertime of 1.4–1.9 s against wall clocks of 65–144 s — so almost none of it is computation;vm_statpageouts moved 1,052,711 → 1,058,258 across the whole run, which is background noise from other builds.That looked like paging at first, given the
systime and the memory floor, and it simply isn't — the numbers above refute it. What the profile actually looks like is a large fixed number of small, individually-blocking storage operations.Where they are, as far as we have traced:
fluree-db-indexer/src/build/incremental.rs, in the V6 Phase-2 branch-update stage.:841schedulestasks=8 concurrency=4 graphs=2— that is 2 graphs × 4 index orders, i.e. structural rather than data-driven, which is consistent with the flat line.:653has each task reportingnew_leaf_count=1while taking 5–8 s. And:3998spends ~5.8 s writing a 6,114-byte index root.One more thing ruled out, which nobody asked for but which pre-empts a plausible wrong guess: a colleague running unrelated annotation work put two single-triple ledgers side by side, one annotated and one not, same machine and same moment, each given one insert and then an incremental
fluree index— 92.5 s vs 91.2 s. The annotation path is conclusively not involved.Ruled out along the way: a sleep (23–47 s of it is
sys), and rayon oversubscription as a cause — it is a ~2× amplifier only (unset 2m19.6 /=21m29.1 /=11m5.6). One correction to something said earlier in this investigation: fsync is a real contributor at roughly 25 % (1m39.1 against 1m14.5 withFLUREE_STORAGE_FSYNC=0). An earlier "not fsync" was measured at the 5 s scale and was under-powered to see it. That still leaves ~74 s unexplained on a loaded box.It is not #1862, and I want to say that explicitly because the two look adjacent. #1862 touches no file under
fluree-db-indexer/src/build/at all — its indexer changes are confined togc/{collector,mod,siblings,sweep}.rs,orchestrator.rs,config.rs,fuel.rs, and alib.rshunk that is purelypub usere-exports. It reclaims what a build produces; it cannot change what a build does, which is what its own "Not covered" note says. The dictionary path is also not the shape it would need to be:compute_affected_leaf_indices(fluree-db-indexer/src/build/dicts.rs:62-165) pre-fetches only affected leaves, so there is no per-build O(ledger) component there to find.The inversion, which is the sharpest single statement of the problem
On the same ledger in the same state, a quiet box, the two commands run back to back:
The incremental merge is 100×+ slower than rebuilding the whole index from scratch. Of everything here this is the number I would trust most: the pair runs on one ledger seconds apart, so it cannot be a load artifact the way the larger absolutes can.
The structural reason is that the two commands do not share a pipeline.
reindexgoes throughrebuild_index_from_commitsand skips thecan_incrementalbranch (fluree-db-indexer/src/lib.rs:212-217) entirely — so it never enters the Phase-2 stage above. It also runs on a dedicated tokio runtime bounded to two worker threads (fluree-db-indexer/src/build/rebuild.rs:34), where the incremental stage uses the process-global rayon pool. I would not lean on that second difference as the cause, though, and I want to flag why rather than let it read as settled: the doc comment directly above that line says the rebuild's CPU parallelism uses its own thread pools rather than tokio workers, so the thread count there is not obviously the thing doing the work. Treat it as an observed structural difference, not a diagnosis.As an interim mitigation, either would help and neither needs the root cause first: route
index_ledgerto the rebuild path below some ledger size, or bound the incremental stage the wayrebuild.rs:34already bounds the rebuild.What is not established
I would rather name the dead end than have someone else walk into it. We do not know which operation emits the ~92k voluntary handoffs. The obvious next step is to sample the process, and that does not work here: the shipped binary is built with
-C strip=symbols, sosample(1)comes back with an empty call graph. Whoever picks this up will need an unstripped build before profiling is worth attempting.The ~74 s residual on a loaded box is likewise unattributed — fsync accounts for roughly a quarter and rayon oversubscription amplifies by about 2×, and that does not add up to the whole.
On the numbers
Two things worth stating so nobody quotes these wrongly.
The working figure is ~5 s. It is not 68 s or 92 s or 144 s. Those larger figures are all from shared boxes under load averages of 12 to 41, and they sit on a smooth curve with load — which is itself informative, given the blocking profile above, but none of them is the cost of an index build. Where a comparison is being drawn, the pairing is the claim and the magnitude is not.
The ~190 MiB memory figure is a floor, not a constant. Peak RSS drifts 186.5 → 199.5 → 229.2 MiB across the 1 k → 700 k ladder, so it is one large fixed allocation with a small data-proportional part on top. And it does not generalize upward: at the 700 k base the full rebuild peaks higher (249 MiB) than the incremental run does. What is anomalous is the floor relative to the work — 186 MiB to merge four triples, 8.5× what a full rebuild of the whole ledger costs at that size — not the absolute number at scale.
All single-machine, M-series macOS,
main@3d89e8f71.bplatz commentedon Oct 22, 2026
Another field report, from an R2RML materialize workload writing into a ledger at a high commit rate:
This fits the fixed per-build cost above. The retention half of that report, where the 15-minute age guard rather than
max_old_indexesdecides how many of those versions stay on disk, is now #2164.