Skip to content

Conversation

@indietyp
Copy link
Member

@indietyp indietyp commented Jan 1, 2026

🌟 What is the purpose of this PR?

Replaces the ResetAllocator pattern with scoped checkpoints in the HashQL MIR transformation pipeline. Instead of resetting the entire scratch allocator between passes, we now use checkpoint()/rollback() semantics and scoped sub-arenas, which provides more granular memory management, and enables more advanced patterns in the future.

🔍 What does this change?

  • Adds Checkpoint type and checkpoint()/rollback() methods to the BumpAllocator trait
  • Updates PreInlining pass to use BumpAllocator::scoped() for each sub-pass instead of resetting the allocator
  • Updates all transformation passes (CopyPropagation, CfgSimplify, InstSimplify, ForwardSubstitution, AdministrativeReduction, DeadStoreElimination, etc.) to work with scoped allocators
  • Updates benchmarks to use the new scoping pattern
  • Uses heap-based tracking for changed state in transformation passes

Pre-Merge Checklist 🚀

🚢 Has this modified a publishable library?

This PR:

  • does not modify any publishable blocks or libraries, or modifications do not need publishing

📜 Does this require a change to the docs?

The changes in this PR:

  • are internal and do not require a docs change

🕸️ Does this require a change to the Turbo Graph?

The changes in this PR:

  • do not affect the execution graph

🛡 What tests cover this?

  • Existing MIR transformation tests and compiletest UI tests

❓ How to test this?

  1. Run cargo nextest run --package hashql-mir
  2. Run transformation benchmarks: `cargo bench --package

@vercel vercel bot temporarily deployed to Preview – petrinaut January 1, 2026 17:59 Inactive
@cursor
Copy link

cursor bot commented Jan 1, 2026

PR Summary

Implements scoped bump allocation and updates MIR transforms to use it for finer-grained memory management.

  • Core allocators: Add Checkpoint and checkpoint()/rollback() to BumpAllocator; implement in Allocator, AllocatorScope, Heap, and Scratch; forward impls for &mut A.
  • MIR passes: Migrate AdministrativeReduction, CfgSimplify, CopyPropagation, InstSimplify, DeadStoreElimination, DeadLocalElimination, and SsaRepair to depend on BumpAllocator and use alloc.scoped(...) instead of reset(); remove reset calls and restructure helpers (e.g., mark_dead_blocks).
  • PreInlining driver: Run each sub-pass in a scope; track per-body Changed state using heap storage; global pass AdministrativeReduction also scoped.
  • ForwardSubstitution: Generalize to Allocator (default Global) instead of Scratch.
  • Benchmarks/compiletests: Update to pass Scratch through closures and reset per-iteration; adapt pass constructors to new_in(scratch).
  • Collections: WorkQueue::new_in now pre-allocates with VecDeque::with_capacity_in(domain_size, ...) to reduce reallocations.

Written by Cursor Bugbot for commit cb4fa90. This will update automatically on new commits. Configure here.

Copy link
Member Author

indietyp commented Jan 1, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@indietyp indietyp force-pushed the bm/be-267-hashql-do-not-reset-the-scratch-space-but-instead-use-scopes branch from 47b5f9f to 67bcdb0 Compare January 1, 2026 18:00
@vercel vercel bot temporarily deployed to Preview – petrinaut January 1, 2026 18:00 Inactive
@vercel vercel bot temporarily deployed to Preview – petrinaut January 1, 2026 18:03 Inactive
@augmentcode
Copy link

augmentcode bot commented Jan 1, 2026

🤖 Augment PR Summary

Summary: Refactors the HashQL MIR transformation pipeline to stop doing full scratch allocator resets between passes and instead rely on scoped bump allocation/checkpoints for finer-grained temporary memory management.

Changes:

  • Adds a Checkpoint type plus BumpAllocator::checkpoint()/rollback(), implemented for Allocator, AllocatorScope, Heap, and Scratch
  • Updates major MIR passes (e.g. CfgSimplify, CopyPropagation, DSE, SSARepair, AdministrativeReduction) to accept BumpAllocator and use alloc.scoped(...) instead of calling reset()
  • Refactors CfgSimplify internals into helper functions and runs sub-passes under allocator scopes
  • Adjusts PreInlining to scope each sub-pass and uses a heap-backed per-body changed-state slice for the fixpoint loop
  • Updates transformation benchmarks to thread a reusable Scratch through each iteration and construct passes with new_in(scratch)
  • Minor allocation improvement: WorkQueue now pre-allocates its VecDeque with domain-sized capacity

Technical Notes: The intent is to enable more granular allocator usage patterns (checkpoint/rollback + sub-arenas) while keeping pass-local allocations short-lived and composable.

🤖 Was this summary useful? React with 👍 or 👎

Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 1 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 1, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing bm/be-267-hashql-do-not-reset-the-scratch-space-but-instead-use-scopes (cb4fa90) with bm/be-266-hashql-implement-pre-inlining-fix-point-loop (99146b5)1

Summary

✅ 17 untouched benchmarks
🗄️ 12 archived benchmarks run2

Footnotes

  1. No successful run was found on bm/be-266-hashql-implement-pre-inlining-fix-point-loop (720ee51) during the generation of this report, so 54e9310 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 12 benchmarks were run, but are now archived. If they were deleted in another branch, consider rebasing to remove them from the report. Instead if they were added back, click here to restore them.

@codecov
Copy link

codecov bot commented Jan 1, 2026

Codecov Report

❌ Patch coverage is 79.71530% with 57 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.02%. Comparing base (720ee51) to head (cb4fa90).

Files with missing lines Patch % Lines
.../hashql/mir/src/pass/transform/cfg_simplify/mod.rs 87.83% 15 Missing and 8 partials ⚠️
libs/@local/hashql/core/src/heap/allocator.rs 0.00% 12 Missing ⚠️
libs/@local/hashql/core/src/heap/bump.rs 0.00% 8 Missing ⚠️
libs/@local/hashql/core/src/heap/mod.rs 0.00% 6 Missing ⚠️
libs/@local/hashql/core/src/heap/scratch.rs 0.00% 6 Missing ⚠️
...hql/mir/src/pass/transform/forward_substitution.rs 0.00% 2 Missing ⚠️
Additional details and impacted files
@@                                     Coverage Diff                                     @@
##           bm/be-266-hashql-implement-pre-inlining-fix-point-loop    #8234       +/-   ##
===========================================================================================
- Coverage                                                   81.20%   64.02%   -17.19%     
===========================================================================================
  Files                                                          82      729      +647     
  Lines                                                       10744    61511    +50767     
  Branches                                                      283     3643     +3360     
===========================================================================================
+ Hits                                                         8725    39383    +30658     
- Misses                                                       1912    21658    +19746     
- Partials                                                      107      470      +363     
Flag Coverage Δ
apps.hash-ai-worker-ts 1.40% <ø> (?)
apps.hash-api 0.00% <ø> (?)
local.hash-graph-sdk 10.88% <ø> (?)
local.hash-isomorphic-utils 0.00% <ø> (?)
rust.hash-graph-api 2.89% <ø> (?)
rust.hashql-ast 87.25% <ø> (?)
rust.hashql-compiletest 46.65% <ø> (ø)
rust.hashql-core 81.63% <3.03%> (?)
rust.hashql-eval 68.54% <ø> (?)
rust.hashql-hir 89.10% <ø> (?)
rust.hashql-mir 87.63% <89.91%> (+0.04%) ⬆️
rust.hashql-syntax-jexpr 94.05% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vercel vercel bot temporarily deployed to Preview – petrinaut January 2, 2026 15:12 Inactive
@graphite-app graphite-app bot requested review from a team January 2, 2026 15:26
@vercel vercel bot temporarily deployed to Preview – petrinaut January 2, 2026 15:49 Inactive
@github-actions
Copy link
Contributor

github-actions bot commented Jan 2, 2026

Benchmark results

@rust/hash-graph-benches – Integrations

policy_resolution_large

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 2002 $$26.3 \mathrm{ms} \pm 172 \mathrm{μs}\left({\color{gray}0.298 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$3.21 \mathrm{ms} \pm 13.0 \mathrm{μs}\left({\color{gray}0.101 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 1001 $$11.7 \mathrm{ms} \pm 72.2 \mathrm{μs}\left({\color{gray}0.108 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 3314 $$41.4 \mathrm{ms} \pm 279 \mathrm{μs}\left({\color{gray}-0.275 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$13.7 \mathrm{ms} \pm 77.1 \mathrm{μs}\left({\color{gray}0.650 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 1526 $$22.7 \mathrm{ms} \pm 132 \mathrm{μs}\left({\color{gray}-0.900 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 2078 $$29.7 \mathrm{ms} \pm 179 \mathrm{μs}\left({\color{lightgreen}-29.003 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.59 \mathrm{ms} \pm 13.4 \mathrm{μs}\left({\color{lightgreen}-82.009 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 1033 $$13.4 \mathrm{ms} \pm 83.3 \mathrm{μs}\left({\color{lightgreen}-50.930 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_medium

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 102 $$3.62 \mathrm{ms} \pm 15.0 \mathrm{μs}\left({\color{gray}-1.301 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.82 \mathrm{ms} \pm 13.1 \mathrm{μs}\left({\color{gray}-0.477 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 51 $$3.17 \mathrm{ms} \pm 14.9 \mathrm{μs}\left({\color{gray}-1.210 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 269 $$4.95 \mathrm{ms} \pm 25.0 \mathrm{μs}\left({\color{gray}0.600 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$3.36 \mathrm{ms} \pm 12.1 \mathrm{μs}\left({\color{gray}0.028 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 107 $$3.91 \mathrm{ms} \pm 19.2 \mathrm{μs}\left({\color{gray}-0.017 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 133 $$4.23 \mathrm{ms} \pm 24.7 \mathrm{μs}\left({\color{gray}2.75 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.26 \mathrm{ms} \pm 13.8 \mathrm{μs}\left({\color{gray}0.205 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 63 $$3.79 \mathrm{ms} \pm 16.4 \mathrm{μs}\left({\color{gray}-1.846 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_none

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 2 $$2.55 \mathrm{ms} \pm 8.90 \mathrm{μs}\left({\color{red}7.92 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.49 \mathrm{ms} \pm 11.3 \mathrm{μs}\left({\color{red}7.46 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 1 $$2.60 \mathrm{ms} \pm 12.3 \mathrm{μs}\left({\color{red}7.98 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 8 $$2.75 \mathrm{ms} \pm 10.0 \mathrm{μs}\left({\color{red}5.33 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.67 \mathrm{ms} \pm 11.1 \mathrm{μs}\left({\color{red}6.36 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 3 $$2.88 \mathrm{ms} \pm 15.3 \mathrm{μs}\left({\color{red}7.10 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_small

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 52 $$2.91 \mathrm{ms} \pm 14.5 \mathrm{μs}\left({\color{red}6.59 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.62 \mathrm{ms} \pm 11.2 \mathrm{μs}\left({\color{red}8.71 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 25 $$2.77 \mathrm{ms} \pm 11.9 \mathrm{μs}\left({\color{red}7.61 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 94 $$3.29 \mathrm{ms} \pm 20.2 \mathrm{μs}\left({\color{red}7.70 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$2.84 \mathrm{ms} \pm 11.9 \mathrm{μs}\left({\color{red}7.92 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 26 $$3.05 \mathrm{ms} \pm 17.5 \mathrm{μs}\left({\color{red}7.23 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 66 $$3.15 \mathrm{ms} \pm 15.3 \mathrm{μs}\left({\color{red}5.25 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.82 \mathrm{ms} \pm 14.2 \mathrm{μs}\left({\color{red}8.61 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 29 $$3.08 \mathrm{ms} \pm 16.6 \mathrm{μs}\left({\color{red}8.39 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_complete

Function Value Mean Flame graphs
entity_by_id;one_depth 1 entities $$38.8 \mathrm{ms} \pm 166 \mathrm{μs}\left({\color{gray}0.371 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 10 entities $$76.0 \mathrm{ms} \pm 397 \mathrm{μs}\left({\color{gray}-0.451 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 25 entities $$43.3 \mathrm{ms} \pm 178 \mathrm{μs}\left({\color{gray}-1.253 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 5 entities $$45.1 \mathrm{ms} \pm 167 \mathrm{μs}\left({\color{gray}-0.399 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 50 entities $$53.2 \mathrm{ms} \pm 246 \mathrm{μs}\left({\color{gray}-0.769 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 1 entities $$40.2 \mathrm{ms} \pm 144 \mathrm{μs}\left({\color{gray}-1.105 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 10 entities $$411 \mathrm{ms} \pm 910 \mathrm{μs}\left({\color{gray}-0.194 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 25 entities $$93.5 \mathrm{ms} \pm 391 \mathrm{μs}\left({\color{gray}0.415 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 5 entities $$84.3 \mathrm{ms} \pm 288 \mathrm{μs}\left({\color{gray}0.279 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 50 entities $$284 \mathrm{ms} \pm 664 \mathrm{μs}\left({\color{gray}3.48 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 1 entities $$14.6 \mathrm{ms} \pm 65.3 \mathrm{μs}\left({\color{gray}2.04 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 10 entities $$14.7 \mathrm{ms} \pm 70.5 \mathrm{μs}\left({\color{gray}0.876 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 25 entities $$15.0 \mathrm{ms} \pm 61.1 \mathrm{μs}\left({\color{gray}0.811 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 5 entities $$14.6 \mathrm{ms} \pm 62.2 \mathrm{μs}\left({\color{gray}0.452 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 50 entities $$17.4 \mathrm{ms} \pm 117 \mathrm{μs}\left({\color{gray}-1.426 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_linkless

Function Value Mean Flame graphs
entity_by_id 1 entities $$14.5 \mathrm{ms} \pm 74.5 \mathrm{μs}\left({\color{gray}-1.137 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$14.7 \mathrm{ms} \pm 74.7 \mathrm{μs}\left({\color{gray}0.228 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 100 entities $$14.6 \mathrm{ms} \pm 66.4 \mathrm{μs}\left({\color{gray}1.80 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1000 entities $$15.1 \mathrm{ms} \pm 78.4 \mathrm{μs}\left({\color{gray}0.855 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10000 entities $$22.1 \mathrm{ms} \pm 130 \mathrm{μs}\left({\color{gray}-0.241 \mathrm{\%}}\right) $$ Flame Graph

representative_read_entity

Function Value Mean Flame graphs
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/block/v/1 $$29.1 \mathrm{ms} \pm 308 \mathrm{μs}\left({\color{gray}-1.239 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1 $$30.0 \mathrm{ms} \pm 205 \mathrm{μs}\left({\color{gray}4.21 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1 $$28.9 \mathrm{ms} \pm 231 \mathrm{μs}\left({\color{gray}-1.108 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1 $$29.1 \mathrm{ms} \pm 281 \mathrm{μs}\left({\color{gray}-0.524 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/page/v/2 $$29.1 \mathrm{ms} \pm 246 \mathrm{μs}\left({\color{gray}0.493 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1 $$29.1 \mathrm{ms} \pm 288 \mathrm{μs}\left({\color{gray}-4.814 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/playlist/v/1 $$28.9 \mathrm{ms} \pm 257 \mathrm{μs}\left({\color{gray}-0.216 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1 $$29.1 \mathrm{ms} \pm 258 \mathrm{μs}\left({\color{gray}0.986 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1 $$29.2 \mathrm{ms} \pm 276 \mathrm{μs}\left({\color{gray}1.19 \mathrm{\%}}\right) $$ Flame Graph

representative_read_entity_type

Function Value Mean Flame graphs
get_entity_type_by_id Account ID: bf5a9ef5-dc3b-43cf-a291-6210c0321eba $$8.04 \mathrm{ms} \pm 27.6 \mathrm{μs}\left({\color{gray}0.662 \mathrm{\%}}\right) $$ Flame Graph

representative_read_multiple_entities

Function Value Mean Flame graphs
entity_by_property traversal_paths=0 0 $$45.2 \mathrm{ms} \pm 293 \mathrm{μs}\left({\color{gray}-0.338 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=255 1,resolve_depths=inherit:1;values:255;properties:255;links:127;link_dests:126;type:true $$92.7 \mathrm{ms} \pm 288 \mathrm{μs}\left({\color{gray}0.069 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:0;link_dests:0;type:false $$51.0 \mathrm{ms} \pm 380 \mathrm{μs}\left({\color{gray}-0.582 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:1;link_dests:0;type:true $$58.9 \mathrm{ms} \pm 281 \mathrm{μs}\left({\color{gray}-0.494 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:2;links:1;link_dests:0;type:true $$67.2 \mathrm{ms} \pm 326 \mathrm{μs}\left({\color{gray}-0.055 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:2;properties:2;links:1;link_dests:0;type:true $$74.2 \mathrm{ms} \pm 364 \mathrm{μs}\left({\color{gray}0.614 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=0 0 $$48.5 \mathrm{ms} \pm 198 \mathrm{μs}\left({\color{gray}-0.822 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=255 1,resolve_depths=inherit:1;values:255;properties:255;links:127;link_dests:126;type:true $$75.1 \mathrm{ms} \pm 260 \mathrm{μs}\left({\color{gray}-0.892 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:0;link_dests:0;type:false $$55.8 \mathrm{ms} \pm 357 \mathrm{μs}\left({\color{gray}0.457 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:1;link_dests:0;type:true $$62.4 \mathrm{ms} \pm 253 \mathrm{μs}\left({\color{gray}-0.904 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:2;links:1;link_dests:0;type:true $$64.8 \mathrm{ms} \pm 311 \mathrm{μs}\left({\color{gray}-0.585 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:2;properties:2;links:1;link_dests:0;type:true $$64.8 \mathrm{ms} \pm 320 \mathrm{μs}\left({\color{gray}0.091 \mathrm{\%}}\right) $$

scenarios

Function Value Mean Flame graphs
full_test query-limited $$138 \mathrm{ms} \pm 451 \mathrm{μs}\left({\color{red}7.05 \mathrm{\%}}\right) $$ Flame Graph
full_test query-unlimited $$136 \mathrm{ms} \pm 535 \mathrm{μs}\left({\color{gray}3.71 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-limited $$39.3 \mathrm{ms} \pm 169 \mathrm{μs}\left({\color{lightgreen}-62.310 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-unlimited $$579 \mathrm{ms} \pm 888 \mathrm{μs}\left({\color{gray}-4.956 \mathrm{\%}}\right) $$ Flame Graph

@vercel
Copy link

vercel bot commented Jan 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Review Updated (UTC)
ds-theme Ignored Ignored Preview Jan 15, 2026 3:23pm
hashdotdesign Ignored Ignored Preview Jan 15, 2026 3:23pm

unsafe fn rollback(&self, checkpoint: Self::Checkpoint) {
// SAFETY: Same safety guarantees as `Allocator::rollback`.
unsafe { self.inner.rollback(checkpoint) }
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heap::rollback doesn't clear interned strings, causing dangling pointers

High Severity

The new Heap::rollback implementation delegates directly to self.inner.rollback(checkpoint) without clearing the strings HashSet. The Heap struct stores interned strings as &'static str pointers that actually point into arena memory (the 'static lifetime is documented as "a lie"). When rollback resets the arena past where strings were interned, the strings HashSet retains dangling pointers. The reset() method correctly clears strings first with an explicit comment about preventing dangling references, but rollback() lacks this handling. This can cause use-after-free when checking string interning after a rollback.

Fix in Cursor Fix in Web

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I... actually didn't think about that. Good point the heap cannot be reset safely. I'll need to think about that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/libs Relates to first-party libraries/crates/packages (area) type/eng > backend Owned by the @backend team

Development

Successfully merging this pull request may close these issues.

2 participants