Skip to content

Cache the fingerprint and size of inline posting lists - #24

Merged
venkat1701 merged 2 commits into
mainfrom
perf/edge-ingest
Oct 4, 2026
Merged

venkat1701 merged 2 commits into
mainfrom
perf/edge-ingest

Conversation

@venkat1701

Copy link
Copy Markdown
Collaborator

Closes #10

I profiled edge ingest before following the plan in the issue, and the plan turned out to be wrong. A transaction's write scope already owns the nodes it copies, so touching the same reverse-index leaf twice in one commit doesn't copy it twice. Sorting the updates wouldn't change the pages written.

The real cost was elsewhere. About 90% of ingest time is commit materialization, and the biggest single piece, around 36%, was recomputing leaf summaries. Freezing a reverse-index leaf re-hashed every inline posting list in it, including the ones the commit never touched, so hub nodes with long posting lists got re-hashed again and again. Leaf.remeasure did the same for encoded sizes on every copy.

Postings.Inline now carries its fingerprint and encoded size. Both are computed once in PostingsCodec.inline when the list is built or decoded, which is already an O(n) step because of the array copy. Summaries and size accounting just read them. The fingerprint formula hasn't changed, so pages and summaries on disk are identical and there's no format change.

Numbers: 60 commits of 1,000 edges on a 50k node database, main and this branch run back to back three times. Wall time was too noisy on this machine (load average around 19 from other containers), so I measured CPU time on the committing thread:

main this branch
12,596 edges per CPU-second 17,772
14,880 17,960
12,956 15,435

Pages and bytes written per commit are identical in every run (1,135 pages, 993 KiB), which is also a nice check that the output didn't change.

The write volume itself, around 1 KiB of pages per edge at this batch size, is what copy-on-write costs for random updates to the reverse index. Bringing that down would need a write buffer in front of the index, which is a bigger design change than this issue.

Full ./mvnw install passes locally, including the crash matrix.

Freezing a reverse-index leaf recomputed its summary by re-hashing every
posting list in it, touched or not, and every copy re-measured their
encoded size the same way. Both are now worked out once when an inline
list is built or decoded. Fingerprints are unchanged, so nothing on disk
moves.
@venkat1701
venkat1701 merged commit 93dfb9b into main Oct 4, 2026
@venkat1701
venkat1701 deleted the perf/edge-ingest branch October 6, 2026 00:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Edge ingest copies incident tree paths for every member

1 participant