Skip to content

Cut redundant work in the graph mutation-apply path - #2321

Open
mcalancea wants to merge 6 commits into
mainfrom
mihai/apply-path-opts
Open

Cut redundant work in the graph mutation-apply path#2321
mcalancea wants to merge 6 commits into
mainfrom
mihai/apply-path-opts

Conversation

@mcalancea

Copy link
Copy Markdown
Collaborator

Two changes to the mutation-apply hot path. No effect on the stored format, checkpoint layout, checksums, or mutation semantics.

Compaction scan: raw-degree guard. compact_batch decoded and staleness-filtered every candidate neighborhood to find the oversized ones. Raw degree — a header read on the encoded form — upper-bounds active degree, so candidates at or under M_limit are now skipped without decoding. Identical output.

Staleness-filter watermark. edit_neighborhood ran the per-entry content-clock filter on every touch. GraphMem now tracks the seq_no of the last op that can invalidate existing edges (RemoveNode, or an AddNode re-minting a live serial); a neighborhood stamped at or after that watermark provably holds no stale edge, so the filter is skipped. The field is derived and in-memory only: loads seed it conservatively at last_update_seq_no, replay maintains it deterministically, and the existing debug_assert in edit_neighborhood guards the skip. GraphMem equality now compares semantic state only (derived fields excluded), so a conservatively seeded load compares equal to its mint.

Measured on a synthetic 17M-node graph on Graviton (x8g), single-threaded: applying a batch of 96 inserts with 320 bilateral links went from 1.64 s to 288 ms, and the compaction candidate scan from ~1.4 s to 1.3 ms. The benchmark harness lands separately.

Raw degree upper-bounds active degree, so a header read soundly skips
candidates that cannot exceed M_limit; only potentially-oversized
neighborhoods pay the decode and staleness filter.
Track the seq_no of the last op that can invalidate edges (RemoveNode,
or AddNode re-minting a live serial). A neighborhood stamped at or after
it holds no stale edge, so edit_neighborhood skips the per-entry
content-clock probes. Derived, in-memory only; equality now compares
semantic state so a conservatively seeded load equals its mint.
@mcalancea
mcalancea marked this pull request as ready for review August 3, 2026 13:45
A loaded graph's history is unknown and legacy prune/migration can leave
edges to serials absent from the content clock; seeding at
last_update_seq_no let neighborhoods stamped at the load height skip
their first filter, admitting restart-dependent state and phantom-edge
resurrection. Seeding one past the load point forces one filtered touch
per loaded neighborhood. Also assert the skip precondition in debug
builds and destructure in PartialEq so new fields force a decision.
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.

1 participant