Skip to content

Conversation

@indietyp
Copy link
Member

🌟 What is the purpose of this PR?

Add support for graph read filter bodies in MIR, enabling property path extraction for graph traversal.

🔍 What does this change?

  • Add GraphReadFilter as a new body source type in the MIR builder guide
  • Implement TraversalExtraction pass to materialize vertex projections in graph read filters
  • Update PostInline to run the traversal extraction pass and collect results
  • Add append method to IdVec for more efficient vector operations
  • Add type_id_unchecked and Display implementation for Place

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?

  • Comprehensive test suite for the traversal extraction pass covering various scenarios
  • Tests verify correct extraction of projections and traversal map generation

@vercel
Copy link

vercel bot commented Jan 27, 2026

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

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

@cursor
Copy link

cursor bot commented Jan 27, 2026

PR Summary

Medium Risk
Changes the post-inlining optimization pipeline and introduces a new MIR-rewriting pass, which could affect codegen/runtime semantics for graph read filters if extraction or state-marking is incorrect.

Overview
Adds a new MIR transform, TraversalExtraction, that materializes vertex projections into dedicated locals for Source::GraphReadFilter bodies and records a Traversals map (extracted local → original projection path) for downstream graph execution.

PostInline is extended from “canonicalization-only” to run canonicalization then traversal extraction, accumulating per-body traversal results via a new PostInlineResidual returned from PostInline::finish; its constructor now requires the Heap, and benchmarks/compiletests are updated accordingly. Supporting utilities are added (IdVec::append, Place::type_id_unchecked + Display, and allocator accessors on Canonicalization), plus body!/docs updates and snapshot-tested coverage for the new pass.

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

@github-actions github-actions bot added area/infra Relates to version control, CI, CD or IaC (area) 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 Jan 27, 2026
This was referenced Jan 27, 2026
@indietyp indietyp force-pushed the bm/be-315-hashql-differentiate-between-graphfilter-sources branch from b14194d to 517b43b Compare February 6, 2026 09:37
@indietyp indietyp force-pushed the bm/be-317-hashql-projectionextraction-for-entity-access branch from 7c14401 to 14af575 Compare February 6, 2026 09:37
@indietyp indietyp force-pushed the bm/be-317-hashql-projectionextraction-for-entity-access branch from 14af575 to bba2a79 Compare February 6, 2026 10:04
@indietyp indietyp force-pushed the bm/be-315-hashql-differentiate-between-graphfilter-sources branch from 517b43b to 4b1ba4c Compare February 6, 2026 10:04
@graphite-app graphite-app bot changed the base branch from bm/be-315-hashql-differentiate-between-graphfilter-sources to graphite-base/8331 February 6, 2026 15:49
@indietyp indietyp force-pushed the bm/be-317-hashql-projectionextraction-for-entity-access branch from bba2a79 to aabfe01 Compare February 9, 2026 14:09
@graphite-app graphite-app bot changed the base branch from graphite-base/8331 to main February 9, 2026 14:10
@graphite-app
Copy link
Contributor

graphite-app bot commented Feb 9, 2026

Merge activity

  • Feb 9, 2:10 PM UTC: Graphite rebased this pull request, because this pull request is set to merge when ready.

@indietyp indietyp added this pull request to the merge queue Feb 9, 2026
Merged via the queue into main with commit e4c6108 Feb 9, 2026
104 of 119 checks passed
@indietyp indietyp deleted the bm/be-317-hashql-projectionextraction-for-entity-access branch February 9, 2026 14:47
@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 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 $$26.6 \mathrm{ms} \pm 172 \mathrm{μs}\left({\color{gray}-0.930 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$3.21 \mathrm{ms} \pm 14.8 \mathrm{μs}\left({\color{gray}-0.511 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 1001 $$12.0 \mathrm{ms} \pm 73.9 \mathrm{μs}\left({\color{gray}0.814 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 3314 $$42.3 \mathrm{ms} \pm 370 \mathrm{μs}\left({\color{gray}1.50 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$13.8 \mathrm{ms} \pm 75.3 \mathrm{μs}\left({\color{gray}0.112 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 1526 $$23.2 \mathrm{ms} \pm 141 \mathrm{μs}\left({\color{gray}-0.196 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 2078 $$27.7 \mathrm{ms} \pm 170 \mathrm{μs}\left({\color{gray}-0.095 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.51 \mathrm{ms} \pm 15.1 \mathrm{μs}\left({\color{gray}-0.677 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 1033 $$13.1 \mathrm{ms} \pm 91.0 \mathrm{μs}\left({\color{gray}0.835 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_medium

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 102 $$3.62 \mathrm{ms} \pm 18.4 \mathrm{μs}\left({\color{gray}-0.245 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.82 \mathrm{ms} \pm 15.4 \mathrm{μs}\left({\color{gray}-0.359 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 51 $$3.17 \mathrm{ms} \pm 12.9 \mathrm{μs}\left({\color{gray}-0.534 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 269 $$5.01 \mathrm{ms} \pm 24.0 \mathrm{μs}\left({\color{gray}0.318 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$3.40 \mathrm{ms} \pm 17.1 \mathrm{μs}\left({\color{gray}0.995 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 107 $$3.96 \mathrm{ms} \pm 17.0 \mathrm{μs}\left({\color{gray}0.475 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 133 $$4.27 \mathrm{ms} \pm 22.3 \mathrm{μs}\left({\color{gray}-0.431 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$3.26 \mathrm{ms} \pm 15.7 \mathrm{μs}\left({\color{gray}-1.790 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 63 $$3.87 \mathrm{ms} \pm 18.7 \mathrm{μs}\left({\color{gray}-0.153 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_none

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 2 $$2.60 \mathrm{ms} \pm 15.2 \mathrm{μs}\left({\color{gray}0.589 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.53 \mathrm{ms} \pm 12.2 \mathrm{μs}\left({\color{gray}0.420 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 1 $$2.64 \mathrm{ms} \pm 10.7 \mathrm{μs}\left({\color{gray}0.006 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 8 $$2.91 \mathrm{ms} \pm 12.1 \mathrm{μs}\left({\color{gray}0.165 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.71 \mathrm{ms} \pm 11.3 \mathrm{μs}\left({\color{gray}0.212 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 3 $$2.98 \mathrm{ms} \pm 12.1 \mathrm{μs}\left({\color{gray}0.161 \mathrm{\%}}\right) $$ Flame Graph

policy_resolution_small

Function Value Mean Flame graphs
resolve_policies_for_actor user: empty, selectivity: high, policies: 52 $$2.95 \mathrm{ms} \pm 12.8 \mathrm{μs}\left({\color{gray}-0.273 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: low, policies: 1 $$2.63 \mathrm{ms} \pm 12.7 \mathrm{μs}\left({\color{gray}-0.512 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: empty, selectivity: medium, policies: 25 $$2.81 \mathrm{ms} \pm 14.5 \mathrm{μs}\left({\color{gray}0.410 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: high, policies: 94 $$3.34 \mathrm{ms} \pm 13.5 \mathrm{μs}\left({\color{gray}0.168 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: low, policies: 1 $$2.89 \mathrm{ms} \pm 13.8 \mathrm{μs}\left({\color{gray}0.658 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: seeded, selectivity: medium, policies: 26 $$3.16 \mathrm{ms} \pm 16.8 \mathrm{μs}\left({\color{gray}1.27 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: high, policies: 66 $$3.28 \mathrm{ms} \pm 17.5 \mathrm{μs}\left({\color{gray}0.642 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: low, policies: 1 $$2.86 \mathrm{ms} \pm 13.1 \mathrm{μs}\left({\color{gray}-0.411 \mathrm{\%}}\right) $$ Flame Graph
resolve_policies_for_actor user: system, selectivity: medium, policies: 29 $$3.14 \mathrm{ms} \pm 20.4 \mathrm{μs}\left({\color{gray}1.01 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_complete

Function Value Mean Flame graphs
entity_by_id;one_depth 1 entities $$39.6 \mathrm{ms} \pm 197 \mathrm{μs}\left({\color{gray}1.79 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 10 entities $$76.4 \mathrm{ms} \pm 386 \mathrm{μs}\left({\color{gray}0.596 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 25 entities $$43.1 \mathrm{ms} \pm 162 \mathrm{μs}\left({\color{gray}0.939 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 5 entities $$46.4 \mathrm{ms} \pm 246 \mathrm{μs}\left({\color{gray}2.13 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;one_depth 50 entities $$52.8 \mathrm{ms} \pm 285 \mathrm{μs}\left({\color{gray}-1.519 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 1 entities $$41.3 \mathrm{ms} \pm 184 \mathrm{μs}\left({\color{gray}1.52 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 10 entities $$425 \mathrm{ms} \pm 708 \mathrm{μs}\left({\color{gray}2.25 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 25 entities $$95.9 \mathrm{ms} \pm 418 \mathrm{μs}\left({\color{gray}1.45 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 5 entities $$84.8 \mathrm{ms} \pm 386 \mathrm{μs}\left({\color{gray}0.279 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;two_depth 50 entities $$314 \mathrm{ms} \pm 640 \mathrm{μs}\left({\color{gray}1.09 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 1 entities $$14.8 \mathrm{ms} \pm 64.4 \mathrm{μs}\left({\color{gray}-0.845 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 10 entities $$14.9 \mathrm{ms} \pm 65.3 \mathrm{μs}\left({\color{gray}-0.289 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 25 entities $$15.4 \mathrm{ms} \pm 88.2 \mathrm{μs}\left({\color{gray}1.18 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 5 entities $$15.0 \mathrm{ms} \pm 57.7 \mathrm{μs}\left({\color{gray}-0.225 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id;zero_depth 50 entities $$17.9 \mathrm{ms} \pm 79.2 \mathrm{μs}\left({\color{gray}0.774 \mathrm{\%}}\right) $$ Flame Graph

read_scaling_linkless

Function Value Mean Flame graphs
entity_by_id 1 entities $$15.0 \mathrm{ms} \pm 64.4 \mathrm{μs}\left({\color{gray}-0.433 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10 entities $$14.9 \mathrm{ms} \pm 81.8 \mathrm{μs}\left({\color{gray}0.895 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 100 entities $$14.9 \mathrm{ms} \pm 74.8 \mathrm{μs}\left({\color{gray}1.01 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 1000 entities $$15.4 \mathrm{ms} \pm 66.2 \mathrm{μs}\left({\color{gray}0.091 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id 10000 entities $$22.4 \mathrm{ms} \pm 162 \mathrm{μs}\left({\color{gray}-0.609 \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.7 \mathrm{ms} \pm 265 \mathrm{μs}\left({\color{gray}0.796 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/book/v/1 $$29.4 \mathrm{ms} \pm 284 \mathrm{μs}\left({\color{gray}-2.373 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/building/v/1 $$29.3 \mathrm{ms} \pm 262 \mathrm{μs}\left({\color{gray}0.500 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/organization/v/1 $$30.2 \mathrm{ms} \pm 301 \mathrm{μs}\left({\color{gray}0.439 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/page/v/2 $$29.5 \mathrm{ms} \pm 305 \mathrm{μs}\left({\color{gray}-1.037 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/person/v/1 $$30.2 \mathrm{ms} \pm 275 \mathrm{μs}\left({\color{gray}2.77 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/playlist/v/1 $$29.3 \mathrm{ms} \pm 279 \mathrm{μs}\left({\color{gray}-3.403 \mathrm{\%}}\right) $$ Flame Graph
entity_by_id entity type ID: https://blockprotocol.org/@alice/types/entity-type/song/v/1 $$29.8 \mathrm{ms} \pm 264 \mathrm{μs}\left({\color{gray}0.826 \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 277 \mathrm{μs}\left({\color{gray}-1.386 \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.12 \mathrm{ms} \pm 43.5 \mathrm{μs}\left({\color{gray}0.852 \mathrm{\%}}\right) $$ Flame Graph

representative_read_multiple_entities

Function Value Mean Flame graphs
entity_by_property traversal_paths=0 0 $$89.1 \mathrm{ms} \pm 485 \mathrm{μs}\left({\color{gray}0.304 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=255 1,resolve_depths=inherit:1;values:255;properties:255;links:127;link_dests:126;type:true $$139 \mathrm{ms} \pm 452 \mathrm{μs}\left({\color{gray}-0.071 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:0;link_dests:0;type:false $$94.8 \mathrm{ms} \pm 410 \mathrm{μs}\left({\color{gray}-0.622 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:0;links:1;link_dests:0;type:true $$104 \mathrm{ms} \pm 510 \mathrm{μs}\left({\color{gray}-0.211 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:0;properties:2;links:1;link_dests:0;type:true $$112 \mathrm{ms} \pm 404 \mathrm{μs}\left({\color{gray}-0.818 \mathrm{\%}}\right) $$
entity_by_property traversal_paths=2 1,resolve_depths=inherit:0;values:2;properties:2;links:1;link_dests:0;type:true $$119 \mathrm{ms} \pm 512 \mathrm{μs}\left({\color{gray}-0.012 \mathrm{\%}}\right) $$
link_by_source_by_property traversal_paths=0 0 $$87.2 \mathrm{ms} \pm 441 \mathrm{μs}\left({\color{gray}0.657 \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 $$114 \mathrm{ms} \pm 471 \mathrm{μs}\left({\color{gray}-0.085 \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 $$94.1 \mathrm{ms} \pm 438 \mathrm{μs}\left({\color{gray}0.131 \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 $$102 \mathrm{ms} \pm 509 \mathrm{μs}\left({\color{gray}-0.071 \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 $$104 \mathrm{ms} \pm 467 \mathrm{μs}\left({\color{gray}-0.097 \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 $$104 \mathrm{ms} \pm 494 \mathrm{μs}\left({\color{gray}0.080 \mathrm{\%}}\right) $$

scenarios

Function Value Mean Flame graphs
full_test query-limited $$139 \mathrm{ms} \pm 550 \mathrm{μs}\left({\color{red}8.88 \mathrm{\%}}\right) $$ Flame Graph
full_test query-unlimited $$142 \mathrm{ms} \pm 618 \mathrm{μs}\left({\color{red}13.8 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-limited $$106 \mathrm{ms} \pm 586 \mathrm{μs}\left({\color{red}175 \mathrm{\%}}\right) $$ Flame Graph
linked_queries query-unlimited $$609 \mathrm{ms} \pm 2.38 \mathrm{ms}\left({\color{red}10.3 \mathrm{\%}}\right) $$ Flame Graph

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/infra Relates to version control, CI, CD or IaC (area) 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