Skip to content

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

Merged
indietyp merged 18 commits intomainfrom
bm/be-303-hashql-split-basic-blocks-depending-on-largest-available
Feb 21, 2026
Merged

BE-303: HashQL: Split MIR basic blocks by target support#8354
indietyp merged 18 commits intomainfrom
bm/be-303-hashql-split-basic-blocks-depending-on-largest-available

Conversation

@indietyp
Copy link
Copy Markdown
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
Copy Markdown

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 20, 2026 5:11pm
petrinaut Ready Ready Preview Feb 20, 2026 5:11pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
hashdotdesign Ignored Ignored Preview Feb 20, 2026 5:11pm
hashdotdesign-tokens Ignored Ignored Preview Feb 20, 2026 5:11pm

@cursor
Copy link
Copy Markdown

cursor Bot commented Feb 3, 2026

PR Summary

Medium Risk
Medium risk because it changes MIR control-flow/block layout (ID remapping and inserted Goto chains) and updates cost indexing utilities; incorrect splitting/remapping could break downstream analyses despite strong test coverage.

Overview
Adds a new execution::splitting pass (BasicBlockSplitting) that partitions MIR BasicBlocks whenever per-statement target support changes, remaps all BasicBlockId references, inserts Goto chains between split blocks, and produces per-block TargetBitSet affinities for downstream scheduling.

Refactors execution-target plumbing to support this: reworks TargetId into an enum implementing Id, introduces TargetArray/TargetBitSet (using new core IdArray and a re-implemented FiniteBitSet), and extends StatementCostVec with offset remapping/helpers needed after block splitting.

Adds extensive unit + snapshot tests covering region counting, splitting behavior, block-reference rewriting, and cost remapping, plus small core utilities (IdSlice::windows, feature gates) to support the new structures.

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

@vercel vercel Bot temporarily deployed to Preview – petrinaut February 11, 2026 22:03 Inactive
Comment thread libs/@local/hashql/mir/src/pass/analysis/execution/splitting/mod.rs
@graphite-app graphite-app Bot changed the base branch from bm/be-364-hashql-rework-symbol-to-be-faster-and-smaller to graphite-base/8354 February 17, 2026 09:16
TimDiekmann
TimDiekmann previously approved these changes Feb 19, 2026
@indietyp indietyp force-pushed the bm/be-303-hashql-split-basic-blocks-depending-on-largest-available branch from d25735c to c40fc37 Compare February 19, 2026 13:57
@indietyp indietyp changed the base branch from graphite-base/8354 to bm/be-364-hashql-rework-symbol-to-be-faster-and-smaller February 19, 2026 13:58
Base automatically changed from bm/be-364-hashql-rework-symbol-to-be-faster-and-smaller to main February 19, 2026 15:26
@indietyp indietyp force-pushed the bm/be-303-hashql-split-basic-blocks-depending-on-largest-available branch from c40fc37 to f78453b Compare February 19, 2026 15:27
@vercel vercel Bot temporarily deployed to Preview – petrinaut February 19, 2026 15:27 Inactive
@github-actions github-actions Bot dismissed TimDiekmann’s stale review February 19, 2026 15:27

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/22188101486

@graphite-app
Copy link
Copy Markdown
Contributor

graphite-app Bot commented Feb 19, 2026

Merge activity

  • Feb 19, 3:27 PM UTC: Graphite rebased this pull request, because this pull request is set to merge when ready.

Copy link
Copy Markdown

@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.

Comment thread libs/@local/hashql/mir/src/pass/analysis/execution/cost.rs
@github-actions
Copy link
Copy Markdown
Contributor

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.6 \mathrm{ms} \pm 178 \mathrm{μs}\left({\color{gray}1.18 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$3.19 \mathrm{ms} \pm 12.5 \mathrm{μs}\left({\color{gray}-0.029 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 1001 $$11.7 \mathrm{ms} \pm 93.7 \mathrm{μs}\left({\color{gray}-1.494 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 3314 $$41.8 \mathrm{ms} \pm 344 \mathrm{μs}\left({\color{gray}0.194 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$13.6 \mathrm{ms} \pm 71.3 \mathrm{μs}\left({\color{gray}0.567 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 1526 $$23.5 \mathrm{ms} \pm 179 \mathrm{μs}\left({\color{gray}2.80 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 2078 $$27.6 \mathrm{ms} \pm 173 \mathrm{μs}\left({\color{gray}-0.004 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.50 \mathrm{ms} \pm 23.4 \mathrm{μs}\left({\color{gray}1.13 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 1033 $$12.7 \mathrm{ms} \pm 81.9 \mathrm{μs}\left({\color{gray}-1.334 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_medium

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 102 $$3.57 \mathrm{ms} \pm 16.4 \mathrm{μs}\left({\color{gray}-0.530 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.81 \mathrm{ms} \pm 12.6 \mathrm{μs}\left({\color{gray}0.195 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 51 $$3.15 \mathrm{ms} \pm 18.4 \mathrm{μs}\left({\color{gray}0.610 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 269 $$4.92 \mathrm{ms} \pm 20.4 \mathrm{μs}\left({\color{gray}-0.226 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$3.36 \mathrm{ms} \pm 13.8 \mathrm{μs}\left({\color{gray}0.209 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 107 $$3.90 \mathrm{ms} \pm 16.7 \mathrm{μs}\left({\color{gray}-0.146 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 133 $$4.21 \mathrm{ms} \pm 22.1 \mathrm{μs}\left({\color{gray}-0.307 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.23 \mathrm{ms} \pm 15.7 \mathrm{μs}\left({\color{gray}0.089 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 63 $$3.82 \mathrm{ms} \pm 21.4 \mathrm{μs}\left({\color{gray}0.093 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_none

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 2 $$2.54 \mathrm{ms} \pm 8.74 \mathrm{μs}\left({\color{gray}-0.609 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.50 \mathrm{ms} \pm 9.54 \mathrm{μs}\left({\color{gray}0.084 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 1 $$2.61 \mathrm{ms} \pm 11.2 \mathrm{μs}\left({\color{gray}0.310 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 8 $$2.87 \mathrm{ms} \pm 15.1 \mathrm{μs}\left({\color{gray}0.255 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.66 \mathrm{ms} \pm 10.2 \mathrm{μs}\left({\color{gray}-0.027 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 3 $$2.95 \mathrm{ms} \pm 13.5 \mathrm{μs}\left({\color{gray}0.681 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_small

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 52 $$2.90 \mathrm{ms} \pm 12.5 \mathrm{μs}\left({\color{gray}0.557 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.61 \mathrm{ms} \pm 12.1 \mathrm{μs}\left({\color{gray}0.913 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 25 $$2.77 \mathrm{ms} \pm 13.2 \mathrm{μs}\left({\color{gray}0.254 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 94 $$3.29 \mathrm{ms} \pm 13.1 \mathrm{μs}\left({\color{gray}-0.530 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$2.88 \mathrm{ms} \pm 14.8 \mathrm{μs}\left({\color{gray}1.38 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 26 $$3.11 \mathrm{ms} \pm 15.9 \mathrm{μs}\left({\color{gray}0.308 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 66 $$3.23 \mathrm{ms} \pm 14.7 \mathrm{μs}\left({\color{gray}-0.067 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.82 \mathrm{ms} \pm 11.2 \mathrm{μs}\left({\color{gray}0.638 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 29 $$3.08 \mathrm{ms} \pm 13.9 \mathrm{μs}\left({\color{gray}0.406 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_complete

Function Value Mean Flame graphs
entity_by_id;one_depth 1 entities $$38.7 \mathrm{ms} \pm 164 \mathrm{μs}\left({\color{gray}-0.128 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 10 entities $$74.9 \mathrm{ms} \pm 349 \mathrm{μs}\left({\color{gray}-1.123 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 25 entities $$42.4 \mathrm{ms} \pm 151 \mathrm{μs}\left({\color{gray}0.395 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 5 entities $$45.3 \mathrm{ms} \pm 175 \mathrm{μs}\left({\color{gray}0.850 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 50 entities $$52.7 \mathrm{ms} \pm 242 \mathrm{μs}\left({\color{gray}0.548 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 1 entities $$40.4 \mathrm{ms} \pm 196 \mathrm{μs}\left({\color{gray}0.296 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 10 entities $$415 \mathrm{ms} \pm 989 \mathrm{μs}\left({\color{gray}1.52 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 25 entities $$88.6 \mathrm{ms} \pm 486 \mathrm{μs}\left({\color{lightgreen}-5.946 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 5 entities $$84.2 \mathrm{ms} \pm 406 \mathrm{μs}\left({\color{gray}0.380 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 50 entities $$305 \mathrm{ms} \pm 1.16 \mathrm{ms}\left({\color{red}10.9 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 1 entities $$14.8 \mathrm{ms} \pm 69.2 \mathrm{μs}\left({\color{gray}2.04 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 10 entities $$14.8 \mathrm{ms} \pm 82.1 \mathrm{μs}\left({\color{gray}1.55 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 25 entities $$15.0 \mathrm{ms} \pm 61.0 \mathrm{μs}\left({\color{gray}0.896 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 5 entities $$14.7 \mathrm{ms} \pm 76.9 \mathrm{μs}\left({\color{gray}-0.290 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 50 entities $$17.5 \mathrm{ms} \pm 112 \mathrm{μs}\left({\color{gray}-1.141 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_linkless

Function Value Mean Flame graphs
entity_by_id 1 entities $$14.9 \mathrm{ms} \pm 58.1 \mathrm{μs}\left({\color{gray}3.23 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$14.6 \mathrm{ms} \pm 62.6 \mathrm{μs}\left({\color{gray}0.559 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 100 entities $$14.5 \mathrm{ms} \pm 82.6 \mathrm{μs}\left({\color{gray}0.024 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1000 entities $$15.1 \mathrm{ms} \pm 77.2 \mathrm{μs}\left({\color{gray}-0.198 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10000 entities $$22.1 \mathrm{ms} \pm 121 \mathrm{μs}\left({\color{gray}-0.655 \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.6 \mathrm{ms} \pm 298 \mathrm{μs}\left({\color{gray}-2.577 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1 $$29.7 \mathrm{ms} \pm 271 \mathrm{μs}\left({\color{gray}4.90 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1 $$29.2 \mathrm{ms} \pm 255 \mathrm{μs}\left({\color{gray}0.038 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1 $$28.4 \mathrm{ms} \pm 263 \mathrm{μs}\left({\color{gray}-3.778 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/page/v/2 $$29.8 \mathrm{ms} \pm 304 \mathrm{μs}\left({\color{gray}0.020 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1 $$29.7 \mathrm{ms} \pm 277 \mathrm{μs}\left({\color{gray}4.56 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/playlist/v/1 $$29.2 \mathrm{ms} \pm 264 \mathrm{μs}\left({\color{gray}-1.699 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1 $$30.0 \mathrm{ms} \pm 262 \mathrm{μs}\left({\color{gray}1.39 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1 $$29.3 \mathrm{ms} \pm 269 \mathrm{μs}\left({\color{gray}-0.296 \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 $$7.92 \mathrm{ms} \pm 36.3 \mathrm{μs}\left({\color{gray}0.176 \mathrm{\%}}\right) $$ Flame Graph

representative_read_multiple_entities

Function Value Mean Flame graphs
entity_by_property traversal_paths=0 0 $$87.2 \mathrm{ms} \pm 415 \mathrm{μs}\left({\color{gray}-0.578 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=255 1,resolve_depths=inherit:1;values:255;properties:255;links:127;link_dests:126;type:true $$137 \mathrm{ms} \pm 502 \mathrm{μs}\left({\color{gray}1.32 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:0;link_dests:0;type:false $$93.6 \mathrm{ms} \pm 471 \mathrm{μs}\left({\color{gray}-0.746 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:1;link_dests:0;type:true $$102 \mathrm{ms} \pm 587 \mathrm{μs}\left({\color{gray}-0.451 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:2;links:1;link_dests:0;type:true $$111 \mathrm{ms} \pm 516 \mathrm{μs}\left({\color{gray}0.182 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:2;properties:2;links:1;link_dests:0;type:true $$118 \mathrm{ms} \pm 632 \mathrm{μs}\left({\color{gray}0.079 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=0 0 $$86.0 \mathrm{ms} \pm 448 \mathrm{μs}\left({\color{gray}0.528 \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 $$113 \mathrm{ms} \pm 551 \mathrm{μs}\left({\color{gray}1.10 \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 $$92.9 \mathrm{ms} \pm 472 \mathrm{μs}\left({\color{gray}0.408 \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 $$99.8 \mathrm{ms} \pm 418 \mathrm{μs}\left({\color{gray}-0.566 \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 $$102 \mathrm{ms} \pm 450 \mathrm{μs}\left({\color{gray}-0.140 \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 $$103 \mathrm{ms} \pm 478 \mathrm{μs}\left({\color{gray}0.958 \mathrm{\%}}\right) $$

scenarios

Function Value Mean Flame graphs
full_test query-limited $$139 \mathrm{ms} \pm 628 \mathrm{μs}\left({\color{red}5.58 \mathrm{\%}}\right) $$ Flame Graph
full_test query-unlimited $$136 \mathrm{ms} \pm 376 \mathrm{μs}\left({\color{red}5.36 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-limited $$102 \mathrm{ms} \pm 576 \mathrm{μs}\left({\color{red}27.3 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-unlimited $$574 \mathrm{ms} \pm 1.10 \mathrm{ms}\left({\color{gray}2.63 \mathrm{\%}}\right) $$ Flame Graph

@indietyp indietyp added this pull request to the merge queue Feb 21, 2026
Merged via the queue into main with commit 2729d18 Feb 21, 2026
96 checks passed
@indietyp indietyp deleted the bm/be-303-hashql-split-basic-blocks-depending-on-largest-available branch February 21, 2026 01:35
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.

3 participants