Skip to content

BE-514: HashQL: implement iterative adjustment passes in placement solver#8635

Open
indietyp wants to merge 2 commits intobm/be-500-hashql-forward-substitution-unified-param-resolutionfrom
bm/be-514-hashql-solver-iterate-forwardbackward-passes-to-convergence
Open

BE-514: HashQL: implement iterative adjustment passes in placement solver#8635
indietyp wants to merge 2 commits intobm/be-500-hashql-forward-substitution-unified-param-resolutionfrom
bm/be-514-hashql-solver-iterate-forwardbackward-passes-to-convergence

Conversation

@indietyp
Copy link
Copy Markdown
Member

🌟 What is the purpose of this PR?

This PR enhances the placement solver in the MIR dataflow analysis framework by implementing iterative adjustment passes that alternate direction until convergence. Instead of a simple two-pass approach (forward then backward), the solver now continues refining assignments in alternating directions until no further improvements are found, converging to a better local minimum.

🔍 What does this change?

  • Adds a reverse() method to the Direction enum to toggle between Forward and Backward directions
  • Replaces the single backward refinement pass with iterative adjustment passes that alternate direction until convergence
  • Modifies adjust_trivial() and adjust_cyclic() methods to return boolean flags indicating whether assignments changed
  • Introduces a new run_adjustment() method that processes regions in the specified direction and tracks changes
  • Updates documentation to reflect the new iterative convergence approach rather than the previous two-pass strategy

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 placement solver tests continue to validate the functionality
  • Updated test in backward_pass_keeps_assignment_when_csp_fails() to handle the new return signature

❓ How to test this?

  1. Checkout the branch
  2. Run the existing MIR placement solver tests
  3. Confirm that placement optimization still works correctly with the new iterative approach

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 16, 2026

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

Project Deployment Actions Updated (UTC)
hash Ready Ready Preview, Comment May 4, 2026 11:47am
petrinaut Ready Ready Preview May 4, 2026 11:47am
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
hashdotdesign Ignored Ignored Preview May 4, 2026 11:47am
hashdotdesign-tokens Ignored Ignored Preview May 4, 2026 11:47am

Copy link
Copy Markdown
Member Author

indietyp commented Apr 16, 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.

Copy link
Copy Markdown
Member Author

remind me to add a test case for the reason this fails before merging:

3-node chain A → B → C:

 - Unary costs: u_A(0)=3, u_A(1)=0; u_B(0)=u_B(1)=0; u_C(0)=0
 - Edge costs: A–B mismatch cost 2, B–C mismatch cost 1
 - Start from labeling 000

Backward sweep (sinks first): C stays 0, B stays 0 (given A=0, C=0), A switches to 1 (given B=0). Final: 1,0,0.

But changing only B from 0 to 1 lowers total cost — so the result after one sweep is not a 1-opt local minimum.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 16, 2026

Codecov Report

❌ Patch coverage is 99.43820% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 66.19%. Comparing base (2eb8898) to head (c95bdd2).

Files with missing lines Patch % Lines
...shql/mir/src/pass/execution/placement/solve/mod.rs 97.87% 1 Missing ⚠️
Additional details and impacted files
@@                                        Coverage Diff                                         @@
##           bm/be-500-hashql-forward-substitution-unified-param-resolution    #8635      +/-   ##
==================================================================================================
- Coverage                                                           68.31%   66.19%   -2.12%     
==================================================================================================
  Files                                                                 987      934      -53     
  Lines                                                               93839    84690    -9149     
  Branches                                                             4790     4468     -322     
==================================================================================================
- Hits                                                                64108    56063    -8045     
+ Misses                                                              29072    28071    -1001     
+ Partials                                                              659      556     -103     
Flag Coverage Δ
apps.hash-ai-worker-ts 1.41% <ø> (ø)
apps.hash-api 0.00% <ø> (ø)
local.hash-backend-utils 0.00% <ø> (ø)
local.hash-graph-sdk 9.63% <ø> (ø)
local.hash-isomorphic-utils 0.00% <ø> (ø)
rust.hash-graph-api 2.52% <ø> (ø)
rust.hashql-ast ?
rust.hashql-compiletest 28.26% <ø> (ø)
rust.hashql-eval 79.71% <ø> (ø)
rust.hashql-hir ?
rust.hashql-mir 91.77% <99.43%> (+0.04%) ⬆️

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 Apr 16, 2026

Merging this PR will not alter performance

✅ 24 untouched benchmarks
⏩ 56 skipped benchmarks1


Comparing bm/be-514-hashql-solver-iterate-forwardbackward-passes-to-convergence (c95bdd2) with bm/be-500-hashql-forward-substitution-unified-param-resolution (2675e14)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-500-hashql-forward-substitution-unified-param-resolution (2eb8898) during the generation of this report, so a8481d6 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@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.3 \mathrm{ms} \pm 171 \mathrm{μs}\left({\color{gray}0.534 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$3.51 \mathrm{ms} \pm 15.6 \mathrm{μs}\left({\color{gray}0.308 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 1001 $$13.1 \mathrm{ms} \pm 101 \mathrm{μs}\left({\color{gray}-4.988 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 3314 $$43.3 \mathrm{ms} \pm 300 \mathrm{μs}\left({\color{gray}-1.690 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$15.7 \mathrm{ms} \pm 104 \mathrm{μs}\left({\color{gray}0.572 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 1526 $$24.4 \mathrm{ms} \pm 154 \mathrm{μs}\left({\color{gray}-3.192 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 2078 $$27.3 \mathrm{ms} \pm 174 \mathrm{μs}\left({\color{gray}-3.093 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.90 \mathrm{ms} \pm 22.6 \mathrm{μs}\left({\color{gray}2.66 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 1033 $$14.2 \mathrm{ms} \pm 84.4 \mathrm{μs}\left({\color{lightgreen}-5.045 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_medium

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 102 $$3.72 \mathrm{ms} \pm 20.0 \mathrm{μs}\left({\color{gray}-4.382 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$3.05 \mathrm{ms} \pm 22.3 \mathrm{μs}\left({\color{gray}-2.882 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 51 $$3.36 \mathrm{ms} \pm 16.1 \mathrm{μs}\left({\color{gray}-4.956 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 269 $$5.13 \mathrm{ms} \pm 33.5 \mathrm{μs}\left({\color{lightgreen}-7.296 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$3.57 \mathrm{ms} \pm 16.7 \mathrm{μs}\left({\color{gray}-1.949 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 107 $$4.14 \mathrm{ms} \pm 20.3 \mathrm{μs}\left({\color{lightgreen}-5.363 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 133 $$4.41 \mathrm{ms} \pm 30.2 \mathrm{μs}\left({\color{gray}-4.355 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.47 \mathrm{ms} \pm 19.6 \mathrm{μs}\left({\color{gray}-4.287 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 63 $$4.07 \mathrm{ms} \pm 21.9 \mathrm{μs}\left({\color{lightgreen}-6.675 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_none

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 2 $$2.69 \mathrm{ms} \pm 14.3 \mathrm{μs}\left({\color{gray}2.32 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.55 \mathrm{ms} \pm 14.1 \mathrm{μs}\left({\color{lightgreen}-5.480 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 1 $$2.69 \mathrm{ms} \pm 14.5 \mathrm{μs}\left({\color{gray}-3.489 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 8 $$2.94 \mathrm{ms} \pm 16.0 \mathrm{μs}\left({\color{gray}2.39 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.76 \mathrm{ms} \pm 16.8 \mathrm{μs}\left({\color{gray}0.409 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 3 $$2.93 \mathrm{ms} \pm 15.6 \mathrm{μs}\left({\color{gray}0.989 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_small

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 52 $$2.97 \mathrm{ms} \pm 14.8 \mathrm{μs}\left({\color{gray}-2.628 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.77 \mathrm{ms} \pm 13.8 \mathrm{μs}\left({\color{gray}-0.819 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 25 $$2.98 \mathrm{ms} \pm 16.8 \mathrm{μs}\left({\color{gray}-3.320 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 94 $$3.41 \mathrm{ms} \pm 22.2 \mathrm{μs}\left({\color{gray}-1.123 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$3.11 \mathrm{ms} \pm 21.2 \mathrm{μs}\left({\color{gray}3.20 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 26 $$3.38 \mathrm{ms} \pm 21.5 \mathrm{μs}\left({\color{gray}-4.990 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 66 $$3.31 \mathrm{ms} \pm 18.4 \mathrm{μs}\left({\color{gray}-1.449 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.96 \mathrm{ms} \pm 14.1 \mathrm{μs}\left({\color{gray}-1.432 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 29 $$3.30 \mathrm{ms} \pm 22.0 \mathrm{μs}\left({\color{gray}0.326 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_complete

Function Value Mean Flame graphs
entity_by_id;one_depth 1 entities $$58.6 \mathrm{ms} \pm 405 \mathrm{μs}\left({\color{gray}4.48 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 10 entities $$49.4 \mathrm{ms} \pm 204 \mathrm{μs}\left({\color{gray}3.30 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 25 entities $$53.6 \mathrm{ms} \pm 454 \mathrm{μs}\left({\color{gray}3.51 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 5 entities $$44.6 \mathrm{ms} \pm 265 \mathrm{μs}\left({\color{gray}-3.521 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 50 entities $$69.7 \mathrm{ms} \pm 378 \mathrm{μs}\left({\color{red}7.87 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 1 entities $$66.1 \mathrm{ms} \pm 360 \mathrm{μs}\left({\color{gray}4.09 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 10 entities $$60.4 \mathrm{ms} \pm 359 \mathrm{μs}\left({\color{gray}-0.396 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 25 entities $$108 \mathrm{ms} \pm 487 \mathrm{μs}\left({\color{red}5.53 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 5 entities $$50.1 \mathrm{ms} \pm 259 \mathrm{μs}\left({\color{gray}-0.149 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 50 entities $$284 \mathrm{ms} \pm 685 \mathrm{μs}\left({\color{gray}-4.435 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 1 entities $$20.7 \mathrm{ms} \pm 83.5 \mathrm{μs}\left({\color{gray}2.51 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 10 entities $$21.8 \mathrm{ms} \pm 138 \mathrm{μs}\left({\color{gray}4.47 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 25 entities $$20.8 \mathrm{ms} \pm 112 \mathrm{μs}\left({\color{gray}-3.987 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 5 entities $$21.0 \mathrm{ms} \pm 111 \mathrm{μs}\left({\color{gray}4.30 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 50 entities $$25.6 \mathrm{ms} \pm 140 \mathrm{μs}\left({\color{gray}-2.940 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_linkless

Function Value Mean Flame graphs
entity_by_id 1 entities $$19.2 \mathrm{ms} \pm 98.6 \mathrm{μs}\left({\color{lightgreen}-6.735 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$19.5 \mathrm{ms} \pm 108 \mathrm{μs}\left({\color{lightgreen}-5.209 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 100 entities $$19.4 \mathrm{ms} \pm 95.4 \mathrm{μs}\left({\color{lightgreen}-6.058 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1000 entities $$20.4 \mathrm{ms} \pm 119 \mathrm{μs}\left({\color{lightgreen}-5.536 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10000 entities $$27.3 \mathrm{ms} \pm 274 \mathrm{μs}\left({\color{gray}-3.070 \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 $$36.4 \mathrm{ms} \pm 339 \mathrm{μs}\left({\color{gray}-1.501 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1 $$34.8 \mathrm{ms} \pm 285 \mathrm{μs}\left({\color{gray}0.022 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1 $$35.3 \mathrm{ms} \pm 263 \mathrm{μs}\left({\color{gray}-4.991 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1 $$35.1 \mathrm{ms} \pm 284 \mathrm{μs}\left({\color{gray}-2.444 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/page/v/2 $$34.5 \mathrm{ms} \pm 275 \mathrm{μs}\left({\color{gray}-1.095 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1 $$37.3 \mathrm{ms} \pm 332 \mathrm{μs}\left({\color{red}6.76 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/playlist/v/1 $$36.1 \mathrm{ms} \pm 295 \mathrm{μs}\left({\color{gray}2.16 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1 $$35.8 \mathrm{ms} \pm 344 \mathrm{μs}\left({\color{gray}-3.681 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/uk-address/v/1 $$35.9 \mathrm{ms} \pm 289 \mathrm{μs}\left({\color{gray}-4.145 \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.85 \mathrm{ms} \pm 53.3 \mathrm{μs}\left({\color{gray}2.55 \mathrm{\%}}\right) $$ Flame Graph

representative_read_multiple_entities

Function Value Mean Flame graphs
entity_by_property traversal_paths=0 0 $$97.9 \mathrm{ms} \pm 610 \mathrm{μs}\left({\color{red}5.73 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=255 1,resolve_depths=inherit:1;values:255;properties:255;links:127;link_dests:126;type:true $$147 \mathrm{ms} \pm 759 \mathrm{μs}\left({\color{gray}-0.333 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:0;link_dests:0;type:false $$105 \mathrm{ms} \pm 586 \mathrm{μs}\left({\color{gray}4.94 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:1;link_dests:0;type:true $$119 \mathrm{ms} \pm 706 \mathrm{μs}\left({\color{red}7.84 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:2;links:1;link_dests:0;type:true $$123 \mathrm{ms} \pm 644 \mathrm{μs}\left({\color{gray}4.45 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:2;properties:2;links:1;link_dests:0;type:true $$126 \mathrm{ms} \pm 578 \mathrm{μs}\left({\color{gray}-0.528 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=0 0 $$103 \mathrm{ms} \pm 472 \mathrm{μs}\left({\color{gray}-1.305 \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 $$132 \mathrm{ms} \pm 480 \mathrm{μs}\left({\color{gray}-1.012 \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 $$110 \mathrm{ms} \pm 719 \mathrm{μs}\left({\color{gray}-1.554 \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 $$119 \mathrm{ms} \pm 489 \mathrm{μs}\left({\color{gray}-1.364 \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 $$120 \mathrm{ms} \pm 528 \mathrm{μs}\left({\color{gray}-1.447 \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 $$122 \mathrm{ms} \pm 599 \mathrm{μs}\left({\color{gray}1.19 \mathrm{\%}}\right) $$

scenarios

Function Value Mean Flame graphs
full_test query-limited $$138 \mathrm{ms} \pm 1.50 \mathrm{ms}\left({\color{lightgreen}-25.153 \mathrm{\%}}\right) $$ Flame Graph
full_test query-unlimited $$146 \mathrm{ms} \pm 506 \mathrm{μs}\left({\color{lightgreen}-25.944 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-limited $$39.7 \mathrm{ms} \pm 216 \mathrm{μs}\left({\color{gray}-2.643 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-unlimited $$557 \mathrm{ms} \pm 847 \mathrm{μs}\left({\color{gray}-2.125 \mathrm{\%}}\right) $$ Flame Graph

@indietyp indietyp force-pushed the bm/be-514-hashql-solver-iterate-forwardbackward-passes-to-convergence branch from f528e96 to dadf2c4 Compare April 21, 2026 17:06
@indietyp indietyp force-pushed the bm/be-500-hashql-forward-substitution-unified-param-resolution branch from 77eb677 to 25f3b5e Compare April 21, 2026 17:06
@vercel vercel Bot temporarily deployed to Preview – petrinaut April 21, 2026 17:06 Inactive
@indietyp indietyp force-pushed the bm/be-514-hashql-solver-iterate-forwardbackward-passes-to-convergence branch from 615b96b to aa9bebd Compare April 29, 2026 15:32
@indietyp indietyp force-pushed the bm/be-514-hashql-solver-iterate-forwardbackward-passes-to-convergence branch from aa9bebd to 51e57b4 Compare April 29, 2026 15:40
@indietyp indietyp force-pushed the bm/be-500-hashql-forward-substitution-unified-param-resolution branch 2 times, most recently from d2ad307 to 93fba40 Compare April 29, 2026 15:42
@indietyp indietyp force-pushed the bm/be-514-hashql-solver-iterate-forwardbackward-passes-to-convergence branch from 51e57b4 to 211c141 Compare April 29, 2026 15:42
@indietyp indietyp marked this pull request as ready for review April 29, 2026 15:42
@cursor
Copy link
Copy Markdown

cursor Bot commented Apr 29, 2026

PR Summary

Medium Risk
Changes the core MIR placement optimization loop from a single refinement pass to an iterative, alternating-direction convergence scheme, which can affect final target assignments and runtime. Risk is moderate because it touches solver heuristics/costing for cyclic regions, but is covered by existing/updated tests.

Overview
Updates the MIR placement solver to iterate refinement passes until convergence: after the initial forward greedy assignment, it repeatedly re-evaluates regions in alternating Direction (backward/forward/...) and stops once no region changes.

Refactors refinement to report whether assignments changed (adjust_trivial/adjust_cyclic now return flags), adds Direction::reverse(), and introduces ConstraintSatisfactionMode so cyclic-region solving uses different cost estimation during initial solve vs adjustment. Tests are updated to pass the new CSP mode and handle the new adjust_cyclic return shape.

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

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.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 211c141. Configure here.

Comment thread libs/@local/hashql/mir/src/pass/execution/placement/solve/mod.rs
@graphite-app graphite-app Bot requested review from a team April 29, 2026 15:48
@indietyp indietyp force-pushed the bm/be-500-hashql-forward-substitution-unified-param-resolution branch from 93fba40 to ffe8840 Compare April 29, 2026 15:51
@indietyp indietyp force-pushed the bm/be-514-hashql-solver-iterate-forwardbackward-passes-to-convergence branch from 211c141 to 080f3e8 Compare April 29, 2026 15:51
@augmentcode
Copy link
Copy Markdown

augmentcode Bot commented Apr 29, 2026

🤖 Augment PR Summary

Summary: Enhances the HashQL MIR placement solver by iterating adjustment passes (alternating direction) until assignments stop improving, instead of doing a single backward refinement.

Changes:

  • Added Direction::reverse() to toggle between forward and backward traversal.
  • Introduced ConstraintSatisfactionMode to switch CSP cost-estimation weighting between initial solving and later adjustments.
  • Updated PlacementSolver::run_in to run the forward pass once, then repeat adjustment passes (backward/forward/…) until a pass makes no assignment changes.
  • Refactored adjust_trivial / adjust_cyclic to return whether they changed assignments, and used this to drive convergence.
  • Updated CSP/solver tests for the new constructor signature and return values.

Technical Notes: Adjustment solving for cyclic regions now evaluates candidates with full boundary weighting (via TRIVIAL) and threads this choice through CSP cost estimation via the new mode.

🤖 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. 1 suggestion posted.

Fix All in Augment

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

Comment thread libs/@local/hashql/mir/src/pass/execution/placement/solve/mod.rs
@indietyp indietyp force-pushed the bm/be-500-hashql-forward-substitution-unified-param-resolution branch from ffe8840 to f3d71ce Compare April 30, 2026 08:53
@indietyp indietyp force-pushed the bm/be-514-hashql-solver-iterate-forwardbackward-passes-to-convergence branch from 080f3e8 to 0ca8770 Compare April 30, 2026 08:53
@indietyp indietyp force-pushed the bm/be-514-hashql-solver-iterate-forwardbackward-passes-to-convergence branch from 0ca8770 to b02766e Compare April 30, 2026 09:02
@indietyp indietyp force-pushed the bm/be-500-hashql-forward-substitution-unified-param-resolution branch 2 times, most recently from b0024c0 to ff39943 Compare April 30, 2026 09:04
@indietyp indietyp force-pushed the bm/be-514-hashql-solver-iterate-forwardbackward-passes-to-convergence branch from b02766e to f2b4e96 Compare April 30, 2026 09:04
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.

1 participant