Skip to content

BE-512: HashQL: Allow cross-backend transitions for SwitchInt terminators#8696

Merged
indietyp merged 2 commits into
mainfrom
bm/be-512-hashql-switchint-allow-cross-backend-transitions
Jun 1, 2026
Merged

BE-512: HashQL: Allow cross-backend transitions for SwitchInt terminators#8696
indietyp merged 2 commits into
mainfrom
bm/be-512-hashql-switchint-allow-cross-backend-transitions

Conversation

@indietyp
Copy link
Copy Markdown
Member

@indietyp indietyp commented May 4, 2026

🌟 What is the purpose of this PR?

SwitchInt terminators were previously blocked from generating cross-backend transitions during terminator placement, based on an assumption that coordinating branches across backends would be too complex. This restriction has been lifted, allowing SwitchInt to behave the same as Goto and permit cross-backend transitions. This enables more flexible execution placement for conditional branching logic.

🔍 What does this change?

  • SwitchInt now calls add_goto_transitions instead of being a no-op, enabling cross-backend edge costs to be populated for blocks ending with a SwitchInt terminator.
  • The test switchint_blocks_cross_backend has been renamed to switchint_allows_cross_backend and updated to assert that the Interpreter -> Embedding transition is now reachable with the expected cost.
  • The switchint_edge_targets_are_branch_specific test has been updated to assert that cross-backend transitions are present rather than absent.
  • The terminator placement snapshot has been updated to reflect the newly populated I->E and P->E transitions on edge[1].

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?

  • Updated unit tests in terminator_placement/tests.rs covering SwitchInt cross-backend transition behaviour.
  • Updated snapshot test reflecting the new edge cost matrix output.

❓ How to test this?

  1. Run cargo test in libs/@local/hashql/mir.
  2. Confirm all terminator placement tests pass, including the renamed switchint_allows_cross_backend test.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 4, 2026

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

Project Deployment Actions Updated (UTC)
hash Ready Ready Preview, Comment Jun 1, 2026 2:59pm
petrinaut Ready Ready Preview Jun 1, 2026 2:59pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
hashdotdesign-tokens Ignored Ignored Preview Jun 1, 2026 2:59pm

@vercel vercel Bot temporarily deployed to Preview – petrinaut May 4, 2026 12:52 Inactive
@cursor
Copy link
Copy Markdown

cursor Bot commented May 4, 2026

PR Summary

Medium Risk
Changes execution-planning edge costs for all SwitchInt control flow; planners may choose different backend placements than before, though GraphRead and Postgres loop rules are unchanged.

Overview
SwitchInt terminator edges now use the same backend-transition rules as Goto, so terminator placement can assign cross-backend costs (e.g. Interpreter ↔ Embedding) on conditional branches, not only same-backend or fallback-to-Interpreter paths.

In add_terminator_specific_transitions, SwitchInt is merged with Goto and calls add_goto_transitions instead of leaving cross-backend pairs unset. Unit tests and the terminator-placement snapshot were updated to expect those transitions and costs on SwitchInt edges (including per-branch successor targets).

Note: The module-level transition table in mod.rs still describes the old SwitchInt rule; that comment was not updated in this diff.

Reviewed by Cursor Bugbot for commit 77c29af. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions github-actions Bot added area/libs Relates to first-party libraries/crates/packages (area) type/eng > backend Owned by the @backend team area/tests New or updated tests labels May 4, 2026
This was referenced May 4, 2026
Copy link
Copy Markdown
Member Author

indietyp commented May 4, 2026

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

@augmentcode
Copy link
Copy Markdown

augmentcode Bot commented May 4, 2026

🤖 Augment PR Summary

Summary: Enables cross-backend transitions for blocks ending in SwitchInt terminators, aligning their behavior with Goto during terminator placement.
Changes: Updates the edge-cost matrix population logic and adjusts unit/snapshot tests to assert newly reachable cross-backend paths with expected costs.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@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. No suggestions at this time.

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

@codecov
Copy link
Copy Markdown

codecov Bot commented May 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.08%. Comparing base (02b718a) to head (77c29af).

Additional details and impacted files
@@                          Coverage Diff                           @@
##           bm/be-524-hashql-remove-island-dag    #8696      +/-   ##
======================================================================
- Coverage                               59.09%   59.08%   -0.02%     
======================================================================
  Files                                    1344     1343       -1     
  Lines                                  129787   129730      -57     
  Branches                                 5869     5866       -3     
======================================================================
- Hits                                    76704    76653      -51     
+ Misses                                  52180    52174       -6     
  Partials                                  903      903              
Flag Coverage Δ
apps.hash-ai-worker-ts 1.41% <ø> (ø)
apps.hash-api 0.00% <ø> (ø)
local.hash-backend-utils 2.81% <ø> (ø)
local.hash-graph-sdk 9.63% <ø> (ø)
local.hash-isomorphic-utils 0.00% <ø> (ø)
rust.hash-graph-api 2.52% <ø> (ø)
rust.hashql-compiletest 28.26% <ø> (ø)
rust.hashql-eval 75.69% <ø> (ø)
rust.hashql-mir 86.94% <100.00%> (-0.01%) ⬇️

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.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 4, 2026

Merging this PR will not alter performance

✅ 24 untouched benchmarks
⏩ 56 skipped benchmarks1


Comparing bm/be-512-hashql-switchint-allow-cross-backend-transitions (77c29af) with bm/be-524-hashql-remove-island-dag (30090d9)2

Open in CodSpeed

Footnotes

  1. 56 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

  2. No successful run was found on bm/be-524-hashql-remove-island-dag (02b718a) during the generation of this report, so 0f66027 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@indietyp indietyp force-pushed the bm/be-524-hashql-remove-island-dag branch from 7c2c99f to fed3275 Compare May 25, 2026 13:27
@indietyp indietyp force-pushed the bm/be-512-hashql-switchint-allow-cross-backend-transitions branch from b7cf577 to db1e44d Compare May 25, 2026 13:27
@indietyp indietyp force-pushed the bm/be-524-hashql-remove-island-dag branch from fed3275 to 2ffc3ed Compare May 25, 2026 13:58
@indietyp indietyp force-pushed the bm/be-512-hashql-switchint-allow-cross-backend-transitions branch from db1e44d to 0a4f75a Compare May 25, 2026 13:58
@indietyp indietyp force-pushed the bm/be-524-hashql-remove-island-dag branch from 2ffc3ed to 5aa1fb4 Compare May 25, 2026 14:01
@indietyp indietyp force-pushed the bm/be-512-hashql-switchint-allow-cross-backend-transitions branch from 0a4f75a to 40c3c68 Compare May 25, 2026 14:01
@indietyp indietyp force-pushed the bm/be-512-hashql-switchint-allow-cross-backend-transitions branch from 40c3c68 to f9a8499 Compare May 26, 2026 07:25
@indietyp indietyp force-pushed the bm/be-512-hashql-switchint-allow-cross-backend-transitions branch from f9a8499 to c883c9e Compare May 27, 2026 07:11
@indietyp indietyp force-pushed the bm/be-524-hashql-remove-island-dag branch from 2fc2314 to c62ac8e Compare May 27, 2026 07:11
@indietyp indietyp force-pushed the bm/be-512-hashql-switchint-allow-cross-backend-transitions branch from c883c9e to 7323f1e Compare May 28, 2026 13:27
@indietyp indietyp force-pushed the bm/be-524-hashql-remove-island-dag branch from c62ac8e to 3dfb99e Compare May 28, 2026 13:27
TimDiekmann
TimDiekmann previously approved these changes May 28, 2026
@graphite-app graphite-app Bot changed the base branch from bm/be-524-hashql-remove-island-dag to graphite-base/8696 June 1, 2026 12:58
@indietyp indietyp force-pushed the bm/be-512-hashql-switchint-allow-cross-backend-transitions branch from 7323f1e to 77c29af Compare June 1, 2026 14:52
@indietyp indietyp force-pushed the graphite-base/8696 branch from 3dfb99e to 02b718a Compare June 1, 2026 14:52
@indietyp indietyp changed the base branch from graphite-base/8696 to bm/be-524-hashql-remove-island-dag June 1, 2026 14:52
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