BE-457: HashQL: MIR execution pipeline extensions for postgres compilation#8525
Open
indietyp wants to merge 3 commits intobm/be-456-hashql-entity-type-model-enrichment-and-graph-store-queryfrom
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🌟 What is the purpose of this PR?
Prepares the MIR execution pipeline for consumption by the postgres compiler. The execution analysis now produces a complete
IslandGraph(not just a flat island list), the placement solver and island placement accept external allocators, and the traversal system gains theTraversalPathBitMapandas_symbol()APIs that the SQL generator needs. Also adds a backend switch cost to the terminator placement so cross-backend transitions are no longer free.🔍 What does this change?
Execution analysis (
pass/execution/mod.rs):run()becomesrun_in()with an explicit allocator parameter, returningExecutionAnalysisResidual(assignment + island graph). The island graph is now constructed as part of the analysis rather than left to the caller.run_all_in()which runs the execution analysis over all graph-read bodies in aDefIdSlice.Traversal system (
traversal/mod.rs,traversal/entity.rs):TraversalPathBitMap: per-vertex-type collection ofTraversalPathBitSets with pointwise lattice operations. The postgres compiler uses this to track which paths each island accesses across all vertex types.TraversalPath::as_symbol(): returns a static symbol for each path variant, used as SQL column aliases so the interpreter can locate result columns by name.TraversalPathBitSet::vertex(): returns the vertex type for a bitset.EntityPath::as_symbol()andEntityPath::column_name(): per-path SQL identifiers.Terminator placement (
terminator_placement/mod.rs):TransMatrixgainsAddAssignfor element-wise saturating addition.backend_switch_cost()which encodes a fixed overhead for cross-backend transitions (Postgres to Interpreter: 8, Interpreter to Embedding: 4, etc.). Previously cross-backend transitions had zero inherent cost, so empty blocks were arbitrarily assigned to the interpreter even when staying on postgres was free.Placement solver (
placement/solve/):PlacementSolver::run()becomesrun_in()with allocator parameter.Island graph (
island/graph/mod.rs):IslandGraph::new_in()now takes an allocator for its output storage.Pretty printer (
pretty/text.rs):TextFormatAnnotationsgainsannotate_basic_block()andBasicBlockAnnotationassociated type, plus a blanket impl for&mut T.Builder (
builder/rvalue.rs):RValueBuilder::opaque_entity_uuid()convenience constructor for the common pattern of extracting an entity's UUID.Pre-Merge Checklist 🚀
🚢 Has this modified a publishable library?
This PR:
📜 Does this require a change to the docs?
The changes in this PR:
🕸️ Does this require a change to the Turbo Graph?
The changes in this PR:
The
backend_switch_cost()values (8, 4, etc.) are hand-tuned heuristics. They correctly prevent the solver from arbitrarily switching backends for empty blocks, but a proper cost model would derive these from measured overhead.🛡 What tests cover this?
execution/tests.rs) includingentity_uuid_equality,mixed_postgres_embedding_interpreter,projection_and_apply_splitseq_opaque_entity_uuid)❓ How to test this?