Skip to content

BE-372: HashQL: Add traversal-aware liveness analysis for optimizing entity projections#8363

Open
indietyp wants to merge 2 commits intobm/be-304-hashql-terminator-coloring-based-on-capabilitiesfrom
bm/be-372-hashql-do-not-consider-traversals-during-liveness-analysis
Open

BE-372: HashQL: Add traversal-aware liveness analysis for optimizing entity projections#8363
indietyp wants to merge 2 commits intobm/be-304-hashql-terminator-coloring-based-on-capabilitiesfrom
bm/be-372-hashql-do-not-consider-traversals-during-liveness-analysis

Conversation

@indietyp
Copy link
Member

@indietyp indietyp commented Feb 5, 2026

🌟 What is the purpose of this PR?

This PR adds a traversal-aware liveness analysis that suppresses uses of traversal source locals when assigning to known traversal destinations. This allows dead code elimination to remove source locals when all their uses are through extracted traversals.

🔍 What does this change?

  • Adds TraversalLivenessAnalysis that extends standard liveness analysis with special handling for traversal extraction
  • When a traversal destination is fully defined, uses of the traversal source on the right-hand side are not marked as live
  • Updates TerminatorPlacement to use the traversal-aware liveness analysis
  • Adds comprehensive tests for the new analysis
  • Exposes helper methods on Traversals to check if a local is a traversal destination

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?

  • Added unit tests for TraversalLivenessAnalysis covering various scenarios
  • Updated TerminatorPlacement tests to use the new analysis

@vercel
Copy link

vercel bot commented Feb 5, 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:46pm
3 Skipped Deployments
Project Deployment Actions Updated (UTC)
hashdotdesign Ignored Ignored Preview Feb 6, 2026 3:46pm
hashdotdesign-tokens Ignored Ignored Preview Feb 6, 2026 3:46pm
petrinaut Skipped Skipped Feb 6, 2026 3:46pm

@cursor
Copy link

cursor bot commented Feb 5, 2026

PR Summary

Medium Risk
Changes core dataflow results used for execution planning costs; incorrect skip conditions could under-approximate liveness and lead to invalid backend transition decisions, though behavior is guarded by targeted tests.

Overview
Adds TraversalLivenessAnalysis, a new liveness dataflow variant that suppresses marking the traversal source local as live when fully assigning to a known traversal destination, enabling later passes (e.g., DCE) to drop the source when only projections are used.

Wires this traversal-aware liveness into TerminatorPlacement by requiring a Traversals input and using it when computing live-in sets, which can reduce computed cross-backend transfer costs; updates exports, extends Traversals with contains()/source() helpers (and makes insert available within the crate), and adds snapshot/unit tests covering the new liveness semantics and a transfer-cost regression case.

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

@vercel vercel bot temporarily deployed to Preview – petrinaut February 5, 2026 16:53 Inactive
@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 Feb 5, 2026
This was referenced Feb 5, 2026
Copy link
Member Author

indietyp commented Feb 5, 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.

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 5, 2026

Merging this PR will not alter performance

✅ 21 untouched benchmarks
⏩ 20 skipped benchmarks1


Comparing bm/be-372-hashql-do-not-consider-traversals-during-liveness-analysis (61a2ae7) with bm/be-304-hashql-terminator-coloring-based-on-capabilities (4298d22)2

Open in CodSpeed

Footnotes

  1. 20 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-304-hashql-terminator-coloring-based-on-capabilities (9a0ea84) during the generation of this report, so 367b8a2 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@augmentcode
Copy link

augmentcode bot commented Feb 5, 2026

🤖 Augment PR Summary

Summary: This PR adds traversal-aware liveness analysis to better optimize and cost entity projection traversals in HashQL MIR.

Changes:

  • Introduce TraversalLivenessAnalysis that can suppress liveness gens for a traversal source local when defining a registered traversal destination.
  • Export the new analysis alongside standard LivenessAnalysis.
  • Extend Traversals with contains() and source(), and widen insert visibility for intra-crate use.
  • Update TerminatorPlacement to run traversal-aware liveness and accept a Traversals input.
  • Add new liveness unit tests + insta snapshots, and a terminator-placement regression test showing reduced transfer cost when traversals are present.

Technical Notes: The skip behavior only triggers for Assign statements whose LHS is an unprojected traversal destination local (full definition).

🤖 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. 2 suggestions posted.

Fix All in Augment

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

@codecov
Copy link

codecov bot commented Feb 5, 2026

Codecov Report

❌ Patch coverage is 98.61111% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.15%. Comparing base (9a0ea84) to head (61a2ae7).

Files with missing lines Patch % Lines
...hql/mir/src/pass/analysis/dataflow/liveness/mod.rs 93.18% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@                                      Coverage Diff                                       @@
##           bm/be-304-hashql-terminator-coloring-based-on-capabilities    #8363      +/-   ##
==============================================================================================
+ Coverage                                                       84.09%   84.15%   +0.05%     
==============================================================================================
  Files                                                             346      346              
  Lines                                                           51637    51845     +208     
  Branches                                                         1319     1324       +5     
==============================================================================================
+ Hits                                                            43423    43629     +206     
  Misses                                                           7744     7744              
- Partials                                                          470      472       +2     
Flag Coverage Δ
rust.hashql-compiletest 29.69% <ø> (ø)
rust.hashql-mir 90.88% <98.61%> (+0.09%) ⬆️

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.

@graphite-app graphite-app bot requested review from a team February 5, 2026 17:01
@indietyp indietyp force-pushed the bm/be-304-hashql-terminator-coloring-based-on-capabilities branch from c04d28b to 49dcd92 Compare February 6, 2026 08:29
@indietyp indietyp force-pushed the bm/be-372-hashql-do-not-consider-traversals-during-liveness-analysis branch from 71d18d4 to 45b6a75 Compare February 6, 2026 08:29
@vercel vercel bot temporarily deployed to Preview – petrinaut February 6, 2026 08:29 Inactive
@indietyp indietyp force-pushed the bm/be-304-hashql-terminator-coloring-based-on-capabilities branch from 49dcd92 to 76697d7 Compare February 6, 2026 09:37
@indietyp indietyp force-pushed the bm/be-372-hashql-do-not-consider-traversals-during-liveness-analysis branch from 45b6a75 to 54da85f Compare February 6, 2026 09:37
@vercel vercel bot temporarily deployed to Preview – petrinaut February 6, 2026 09:37 Inactive
@indietyp indietyp force-pushed the bm/be-372-hashql-do-not-consider-traversals-during-liveness-analysis branch from 54da85f to be8a448 Compare February 6, 2026 10:04
@indietyp indietyp force-pushed the bm/be-304-hashql-terminator-coloring-based-on-capabilities branch from 76697d7 to 4298d22 Compare February 6, 2026 10:04
@vercel vercel bot temporarily deployed to Preview – petrinaut February 6, 2026 10:04 Inactive
@indietyp indietyp force-pushed the bm/be-304-hashql-terminator-coloring-based-on-capabilities branch from 4298d22 to 9a0ea84 Compare February 6, 2026 15:40
@indietyp indietyp force-pushed the bm/be-372-hashql-do-not-consider-traversals-during-liveness-analysis branch from be8a448 to 61a2ae7 Compare February 6, 2026 15:40
@vercel vercel bot temporarily deployed to Preview – petrinaut February 6, 2026 15:40 Inactive
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