Skip to content

Tag disk-cached query values with their dep node, not the node index - #71

Closed
xmakro wants to merge 1 commit into
perf/base-0728from
cleanup/fingerprint-value-tags
Closed

Tag disk-cached query values with their dep node, not the node index#71
xmakro wants to merge 1 commit into
perf/base-0728from
cleanup/fingerprint-value-tags

Conversation

@xmakro

@xmakro xmakro commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Disk-cached query values are tagged with their node's SerializedDepNodeIndex, and the load path checks the tag after looking the position up by that same index. That is a fine within-session integrity check, but the index only names a node relative to the session's serialized graph: cross-session value carry (the #35 ladder) needs a tag that still identifies a value's node when the bytes outlive the session that wrote them.

This tags values with the DepNode itself. (kind, key_fingerprint) is unique per node — enforced by the reverse-index collision panic in serialized.rs — so the tag stays exactly as strong a discriminator as the index, while also being stable across sessions. The expected node is threaded from the query layer through try_load_from_disk_fn, so the check now verifies end to end that the decoded bytes belong to the node the query layer asked for, and the load path no longer needs to consult the dep graph.

Side effects keep their index tags: side-effect nodes are exempt from the (kind, key_fingerprint) uniqueness guarantee, so a node tag would be ambiguous for them, and their values are a strictly within-session artifact.

Costs: the tag grows from a varint index (typically 2–3 bytes) to a fixed 18 bytes per cached value, and the HEADER_FORMAT_VERSION bump invalidates existing incremental caches once on upgrade.

The node index only names a node relative to the session's serialized
graph; cross-session value carry needs a tag that still identifies a
value's node when the bytes outlive the session that wrote them.

`(kind, key_fingerprint)` is unique per node for every kind that caches
query values, so tagging with the `DepNode` itself is exactly as strong
a within-session check as the index tag while staying valid across
sessions. The expected node is threaded from the query layer through
`try_load_from_disk_fn`, so the load path checks end to end that the
decoded bytes belong to the node the query layer asked for, without
consulting the dep graph.

Side effects keep their index tags: side-effect nodes are exempt from
the uniqueness guarantee, so a node tag would be ambiguous for them.

The header format version is bumped because the tag changed.
@xmakro
xmakro force-pushed the cleanup/fingerprint-value-tags branch from 9f0eec5 to 3bb2e40 Compare July 29, 2026 11:11
@xmakro xmakro changed the title Tag disk-cached query values with the key fingerprint, not the node index Tag disk-cached query values with their dep node, not the node index Jul 29, 2026
@xmakro xmakro closed this Jul 29, 2026
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