Skip to content

BE-303: HashQL: Split MIR basic blocks by target support#8354

Open
indietyp wants to merge 15 commits intobm/be-364-hashql-rework-symbol-to-be-faster-and-smallerfrom
bm/be-303-hashql-split-basic-blocks-depending-on-largest-available
Open

BE-303: HashQL: Split MIR basic blocks by target support#8354
indietyp wants to merge 15 commits intobm/be-364-hashql-rework-symbol-to-be-faster-and-smallerfrom
bm/be-303-hashql-split-basic-blocks-depending-on-largest-available

Conversation

@indietyp
Copy link
Member

@indietyp indietyp commented Feb 3, 2026

🌟 What is the purpose of this PR?

Introduce a MIR execution-analysis pass that splits basic blocks into contiguous regions with uniform target support, returning per-block target affinities for downstream scheduling.

🔍 What does this change?

  • Add a basic-block splitting pass that remaps block IDs, inserts Goto chains between split regions, and returns target affinities.
  • Add unit and snapshot coverage for splitting behavior and cost remapping.
  • Extend execution-analysis data structures to support target bitsets/arrays and cost remapping.

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?

  • New unit tests and snapshot coverage for the splitting pass.

❓ How to test this?

  • Run the hashql-mir test suite that includes execution spli

@vercel
Copy link

vercel bot commented Feb 3, 2026

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

Project Deployment Actions Updated (UTC)
hash Ready Ready Preview, Comment Feb 6, 2026 3:45pm
petrinaut Ready Ready Preview Feb 6, 2026 3:45pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
hashdotdesign Ignored Ignored Preview Feb 6, 2026 3:45pm
hashdotdesign-tokens Ignored Ignored Preview Feb 6, 2026 3:45pm

@cursor
Copy link

cursor bot commented Feb 3, 2026

PR Summary

Medium Risk
Touches core MIR CFG structure and target ID representation, so incorrect remapping or edge cases in splitting could miswire control flow or misattribute costs; coverage is strong via new unit/snapshot tests.

Overview
Adds a new MIR execution-analysis pass (execution::splitting) that splits BasicBlocks into contiguous regions where all statements share the same supported target set, remaps all BasicBlockId references, and inserts Goto chains to preserve control flow while returning per-block target affinities.

To support this, core ID utilities are extended with a new fixed-size IdArray (typed-ID indexing over [T; N]) and a reworked FiniteBitSet (typed-ID, single-integer bitset with range ops/iter), and MIR’s target identifiers are refactored from a newtype into a TargetId enum with Id impl plus TargetArray/TargetBitSet aliases; StatementCostVec gains offset recomputation (remap) and block-scoped accessors. Extensive unit + snapshot tests validate splitting behavior, ID remapping, and cost remapping.

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

@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 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 $$27.0 \mathrm{ms} \pm 162 \mathrm{μs}\left({\color{lightgreen}-6.990 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$3.23 \mathrm{ms} \pm 14.5 \mathrm{μs}\left({\color{lightgreen}-6.280 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 1001 $$12.1 \mathrm{ms} \pm 90.4 \mathrm{μs}\left({\color{lightgreen}-13.022 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 3314 $$43.3 \mathrm{ms} \pm 288 \mathrm{μs}\left({\color{gray}-1.581 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$14.5 \mathrm{ms} \pm 102 \mathrm{μs}\left({\color{gray}-2.157 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 1526 $$25.0 \mathrm{ms} \pm 173 \mathrm{μs}\left({\color{gray}0.289 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 2078 $$44.6 \mathrm{ms} \pm 189 \mathrm{μs}\left({\color{gray}0.123 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$20.9 \mathrm{ms} \pm 127 \mathrm{μs}\left({\color{gray}0.688 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 1033 $$29.7 \mathrm{ms} \pm 257 \mathrm{μs}\left({\color{gray}1.53 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_medium

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 102 $$3.71 \mathrm{ms} \pm 23.3 \mathrm{μs}\left({\color{gray}0.221 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.96 \mathrm{ms} \pm 15.7 \mathrm{μs}\left({\color{gray}3.28 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 51 $$3.23 \mathrm{ms} \pm 17.0 \mathrm{μs}\left({\color{gray}-1.463 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 269 $$5.05 \mathrm{ms} \pm 29.0 \mathrm{μs}\left({\color{gray}-0.804 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$3.43 \mathrm{ms} \pm 19.4 \mathrm{μs}\left({\color{gray}-0.711 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 107 $$3.97 \mathrm{ms} \pm 20.2 \mathrm{μs}\left({\color{gray}-1.276 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 133 $$4.20 \mathrm{ms} \pm 31.4 \mathrm{μs}\left({\color{gray}-0.248 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.26 \mathrm{ms} \pm 15.3 \mathrm{μs}\left({\color{gray}-1.922 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 63 $$3.92 \mathrm{ms} \pm 22.4 \mathrm{μs}\left({\color{gray}-0.530 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_none

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 2 $$2.39 \mathrm{ms} \pm 12.5 \mathrm{μs}\left({\color{gray}-1.789 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.36 \mathrm{ms} \pm 17.0 \mathrm{μs}\left({\color{gray}-3.649 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 1 $$2.44 \mathrm{ms} \pm 15.3 \mathrm{μs}\left({\color{gray}-1.045 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 8 $$2.68 \mathrm{ms} \pm 13.0 \mathrm{μs}\left({\color{gray}-0.516 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.51 \mathrm{ms} \pm 10.9 \mathrm{μs}\left({\color{gray}-2.148 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 3 $$2.75 \mathrm{ms} \pm 14.1 \mathrm{μs}\left({\color{gray}-0.261 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_small

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 52 $$2.85 \mathrm{ms} \pm 12.0 \mathrm{μs}\left({\color{gray}2.23 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.54 \mathrm{ms} \pm 18.7 \mathrm{μs}\left({\color{gray}3.93 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 25 $$2.66 \mathrm{ms} \pm 14.9 \mathrm{μs}\left({\color{gray}0.460 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 94 $$3.17 \mathrm{ms} \pm 14.0 \mathrm{μs}\left({\color{gray}1.32 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$2.72 \mathrm{ms} \pm 14.1 \mathrm{μs}\left({\color{gray}1.12 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 26 $$2.95 \mathrm{ms} \pm 13.2 \mathrm{μs}\left({\color{gray}1.66 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 66 $$3.17 \mathrm{ms} \pm 20.8 \mathrm{μs}\left({\color{gray}4.26 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.67 \mathrm{ms} \pm 13.0 \mathrm{μs}\left({\color{gray}1.35 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 29 $$2.95 \mathrm{ms} \pm 21.3 \mathrm{μs}\left({\color{gray}3.04 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_complete

Function Value Mean Flame graphs
entity_by_id;one_depth 1 entities $$42.1 \mathrm{ms} \pm 309 \mathrm{μs}\left({\color{gray}3.73 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 10 entities $$75.8 \mathrm{ms} \pm 452 \mathrm{μs}\left({\color{gray}-2.945 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 25 entities $$43.3 \mathrm{ms} \pm 212 \mathrm{μs}\left({\color{gray}-3.907 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 5 entities $$46.3 \mathrm{ms} \pm 259 \mathrm{μs}\left({\color{gray}-0.997 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 50 entities $$54.8 \mathrm{ms} \pm 332 \mathrm{μs}\left({\color{gray}0.844 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 1 entities $$42.6 \mathrm{ms} \pm 273 \mathrm{μs}\left({\color{gray}2.42 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 10 entities $$414 \mathrm{ms} \pm 936 \mathrm{μs}\left({\color{gray}-1.801 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 25 entities $$96.2 \mathrm{ms} \pm 577 \mathrm{μs}\left({\color{gray}-2.868 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 5 entities $$87.4 \mathrm{ms} \pm 413 \mathrm{μs}\left({\color{gray}1.64 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 50 entities $$320 \mathrm{ms} \pm 927 \mathrm{μs}\left({\color{red}13.1 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 1 entities $$14.7 \mathrm{ms} \pm 69.4 \mathrm{μs}\left({\color{gray}-0.289 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 10 entities $$14.6 \mathrm{ms} \pm 84.1 \mathrm{μs}\left({\color{gray}-2.335 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 25 entities $$14.9 \mathrm{ms} \pm 79.7 \mathrm{μs}\left({\color{gray}-1.365 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 5 entities $$14.7 \mathrm{ms} \pm 74.7 \mathrm{μs}\left({\color{gray}-1.644 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 50 entities $$17.5 \mathrm{ms} \pm 85.1 \mathrm{μs}\left({\color{gray}-2.583 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_linkless

Function Value Mean Flame graphs
entity_by_id 1 entities $$15.3 \mathrm{ms} \pm 98.8 \mathrm{μs}\left({\color{gray}3.61 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$14.9 \mathrm{ms} \pm 73.7 \mathrm{μs}\left({\color{gray}0.710 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 100 entities $$14.8 \mathrm{ms} \pm 76.2 \mathrm{μs}\left({\color{gray}1.62 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1000 entities $$15.2 \mathrm{ms} \pm 97.6 \mathrm{μs}\left({\color{gray}1.07 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10000 entities $$22.0 \mathrm{ms} \pm 159 \mathrm{μs}\left({\color{gray}-1.158 \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.4 \mathrm{ms} \pm 300 \mathrm{μs}\left({\color{gray}-2.643 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1 $$30.3 \mathrm{ms} \pm 301 \mathrm{μs}\left({\color{gray}1.76 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1 $$31.3 \mathrm{ms} \pm 279 \mathrm{μs}\left({\color{gray}3.81 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1 $$31.0 \mathrm{ms} \pm 322 \mathrm{μs}\left({\color{gray}3.99 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/page/v/2 $$30.2 \mathrm{ms} \pm 331 \mathrm{μs}\left({\color{gray}2.65 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1 $$30.8 \mathrm{ms} \pm 269 \mathrm{μs}\left({\color{gray}4.19 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/playlist/v/1 $$30.8 \mathrm{ms} \pm 324 \mathrm{μs}\left({\color{gray}4.19 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1 $$30.5 \mathrm{ms} \pm 292 \mathrm{μs}\left({\color{gray}1.83 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1 $$29.6 \mathrm{ms} \pm 298 \mathrm{μs}\left({\color{gray}-1.374 \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.18 \mathrm{ms} \pm 38.3 \mathrm{μs}\left({\color{gray}1.47 \mathrm{\%}}\right) $$ Flame Graph

representative_read_multiple_entities

Function Value Mean Flame graphs
entity_by_property traversal_paths=0 0 $$46.8 \mathrm{ms} \pm 270 \mathrm{μs}\left({\color{gray}0.668 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=255 1,resolve_depths=inherit:1;values:255;properties:255;links:127;link_dests:126;type:true $$93.9 \mathrm{ms} \pm 423 \mathrm{μs}\left({\color{gray}-4.761 \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.6 \mathrm{ms} \pm 316 \mathrm{μs}\left({\color{lightgreen}-6.408 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:1;link_dests:0;type:true $$59.3 \mathrm{ms} \pm 310 \mathrm{μs}\left({\color{lightgreen}-5.188 \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.7 \mathrm{ms} \pm 412 \mathrm{μs}\left({\color{lightgreen}-5.362 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:2;properties:2;links:1;link_dests:0;type:true $$73.0 \mathrm{ms} \pm 340 \mathrm{μs}\left({\color{lightgreen}-6.993 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=0 0 $$50.7 \mathrm{ms} \pm 245 \mathrm{μs}\left({\color{gray}-2.387 \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 $$79.6 \mathrm{ms} \pm 387 \mathrm{μs}\left({\color{gray}1.97 \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 $$58.3 \mathrm{ms} \pm 368 \mathrm{μs}\left({\color{gray}-1.231 \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 $$67.0 \mathrm{ms} \pm 407 \mathrm{μs}\left({\color{gray}0.563 \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 $$70.7 \mathrm{ms} \pm 474 \mathrm{μs}\left({\color{gray}3.71 \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 $$69.2 \mathrm{ms} \pm 328 \mathrm{μs}\left({\color{gray}2.66 \mathrm{\%}}\right) $$

scenarios

Function Value Mean Flame graphs
full_test query-limited $$138 \mathrm{ms} \pm 627 \mathrm{μs}\left({\color{gray}3.02 \mathrm{\%}}\right) $$ Flame Graph
full_test query-unlimited $$135 \mathrm{ms} \pm 545 \mathrm{μs}\left({\color{gray}1.16 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-limited $$38.9 \mathrm{ms} \pm 271 \mathrm{μs}\left({\color{lightgreen}-62.290 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-unlimited $$574 \mathrm{ms} \pm 1.57 \mathrm{ms}\left({\color{lightgreen}-5.256 \mathrm{\%}}\right) $$ Flame Graph

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

@indietyp indietyp force-pushed the bm/be-364-hashql-rework-symbol-to-be-faster-and-smaller branch from 669472a to 95f66b9 Compare February 6, 2026 09:37
@indietyp indietyp force-pushed the bm/be-303-hashql-split-basic-blocks-depending-on-largest-available branch from 77f0621 to 02e1336 Compare February 6, 2026 09:37
@indietyp indietyp force-pushed the bm/be-303-hashql-split-basic-blocks-depending-on-largest-available branch from 02e1336 to ef6aeec Compare February 6, 2026 10:04
@indietyp indietyp force-pushed the bm/be-364-hashql-rework-symbol-to-be-faster-and-smaller branch from 95f66b9 to f2baa38 Compare February 6, 2026 10:04
TimDiekmann
TimDiekmann previously approved these changes Feb 6, 2026
@indietyp indietyp force-pushed the bm/be-303-hashql-split-basic-blocks-depending-on-largest-available branch from ef6aeec to cf5e803 Compare February 6, 2026 15:40
@indietyp indietyp force-pushed the bm/be-364-hashql-rework-symbol-to-be-faster-and-smaller branch from f2baa38 to a78848f Compare February 6, 2026 15:40
@github-actions github-actions bot dismissed TimDiekmann’s stale review February 6, 2026 15:40

Your organization requires reapproval when changes are made, so Graphite has dismissed approvals. See the output of git range-diff at https://github.com/hashintel/hash/actions/runs/21756355661

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) area/tests New or updated tests type/eng > backend Owned by the @backend team

Development

Successfully merging this pull request may close these issues.

2 participants