Skip to content

perf(graph): build prepared relationship indexes with FxHash maps - #833

Merged
jonathanong merged 3 commits into
execute-plan/79dd0742-pr-2-faster-filenode-eq-and-interned-string-hashingfrom
execute-plan/79dd0742-pr-3-fxhash-preparedrelationshipindex-construction
Sep 5, 2026
Merged

perf(graph): build prepared relationship indexes with FxHash maps#833
jonathanong merged 3 commits into
execute-plan/79dd0742-pr-2-faster-filenode-eq-and-interned-string-hashingfrom
execute-plan/79dd0742-pr-3-fxhash-preparedrelationshipindex-construction

Conversation

@jonathanong

@jonathanong jonathanong commented Sep 5, 2026

Copy link
Copy Markdown
Owner

Summary

Build PreparedRelationshipIndex with FxHashMap/FxHashSet (local interned keys, same policy as fx.rs) and replace per-name BTreeSet inserts with Vec + one sort/dedup. Public display order and alias grouping are unchanged.

Local Criterion (source of truth)

Machine: macOS aarch64, rustc 1.96.0, --sample-size 20, NO_MISTAKES_BENCH_SHARD=query. Same machine before/after. CodSpeed is not used as a gate.

bench size before (mean) after (mean) change
index_construction 4096 3.73 ms 3.41 ms −22% n.s.
index_construction 16384 20.19 ms 10.78 ms −45%
scoped_projection 4096 4.31 ms 3.85 ms −8%
scoped_projection 16384 30.01 ms 23.21 ms −30%
unscoped_projection 4096 1.14 ms 1.24 ms +10% n.s.
unscoped_projection 16384 5.29 ms 4.24 ms −19%
Shepherd Journal
  • CodSpeed extract regression reported different runtime environments; local Criterion showed index_construction[16384] −45%. codecov/project/rust: no coverage on head while Rust tests inProgress.
  • First-look CodSpeed comment already minimized; different runtime environments; local Criterion index_construction −45%.
  • Codex quota comments IC_kwDOSaSRXM8AAAABStKfzQ/IC_kwDOSaSRXM8AAAABStKhDA and Sourcery budget review PRR_kwDOSaSRXM8AAAABMTHn8g are bot-limit notices, not code findings; minimize only.
  • Accepted Codex P2 PRRT_kwDOSaSRXM6fhSsD: shrink public_names after the unique-node fill so raw-edge-count reservation is not retained. Rejected P2 PRRT_kwDOSaSRXM6fhXEp: bucket sort/dedup already unique the stored alias vectors; per-bucket sets would hash Node on every push on the construction path this PR is speeding up, and the duplicate clones are a temporary spike. Codex quota comments IC_kwDOSaSRXM8AAAABStOd_g/IC_kwDOSaSRXM8AAAABStQZvA are bot-limit notices; minimize only.
  • Accepted Codex P2 PRRT_kwDOSaSRXM6fhZii: restore SipHash HashSet in project_first_seen because projected outputs are public report edges from repo source, not interned analysis keys (fx.rs).
  • Codex quota comment IC_kwDOSaSRXM8AAAABStTOVQ is a bot-limit notice; minimize only.
  • Rejected Codex P2 PRRT_kwDOSaSRXM6fhdHG: grouped_nodes/nodes_by_name keys are public display strings of interned graph nodes, the same local-path universe fx.rs already hashes with FxHash (PathSet). That is analyzed-repo self-DoS, not network input. SipHash here would undo the measured index-construction win. codecov/project/rust "No coverage information found on head" while native/Rust jobs are still inProgress is upload lag.

@coderabbitai

This comment has been minimized.

@sourcery-ai

This comment has been minimized.

@codecov

This comment has been minimized.

@codspeed-hq

This comment has been minimized.

@jonathanong
jonathanong force-pushed the execute-plan/79dd0742-pr-3-fxhash-preparedrelationshipindex-construction branch from a289092 to a547305 Compare September 5, 2026 07:06
@jonathanong
jonathanong marked this pull request as ready for review September 5, 2026 07:27
@chatgpt-codex-connector

This comment has been minimized.

sourcery-ai[bot]

This comment was marked as resolved.

@chatgpt-codex-connector

This comment has been minimized.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@jonathanong
jonathanong force-pushed the execute-plan/79dd0742-pr-3-fxhash-preparedrelationshipindex-construction branch from a547305 to 38e9fd6 Compare September 5, 2026 07:40
@chatgpt-codex-connector

This comment has been minimized.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

Use FxHash maps/sets and a single sort/dedup per public-name bucket so
index construction does not pay SipHash or BTreeSet insert on local keys.
@jonathanong
jonathanong force-pushed the execute-plan/79dd0742-pr-3-fxhash-preparedrelationshipindex-construction branch from 38e9fd6 to fbced94 Compare September 5, 2026 07:46
@chatgpt-codex-connector

This comment has been minimized.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

Reserve by raw edge count for the first pass, then drop spare HashMap
buckets so duplicate enqueue sites do not keep construction capacity in
the retained PreparedRelationshipIndex.
project_first_seen dedupes public report edges whose paths and job
names come from repository source. FxHash is reserved for interned
analysis keys; restoring HashSet avoids HashDoS on crafted names.
@chatgpt-codex-connector

This comment has been minimized.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@jonathanong
jonathanong merged commit b6f0f40 into main Sep 5, 2026
40 of 41 checks passed
@jonathanong
jonathanong deleted the execute-plan/79dd0742-pr-3-fxhash-preparedrelationshipindex-construction branch September 5, 2026 09:18
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