Repository navigation
perf(compile): reduce GC pressure in ConvertOperatorToPhyOperator - #24279
Merged
mergify[bot] merged 2 commits intoMay 6, 2026
Merged
Conversation
Arena-allocate all PhyOperator nodes and child-pointer slices from two pre-sized slices instead of individual heap allocations per operator. For a 50-operator query this reduces ~150 allocations to ~4. Also avoid allocating an empty receiver slice for operators that are not Connector or Dispatch (the vast majority). Fixes matrixorigin#21116 Co-Authored-By: Claude Opus 4.6 <[email protected]>
ⓘ You've reached your Qodo monthly free-tier limit. Reviews pause until next month — upgrade your plan to continue now, or link your paid account if you already have one. |
ouyuanning
approved these changes
May 6, 2026
Contributor
Merge Queue Status
This pull request spent 59 minutes 32 seconds in the queue, including 59 minutes 16 seconds running CI. Required conditions to merge
|
fengttt
pushed a commit
to fengttt/matrixone
that referenced
this pull request
May 7, 2026
…trixorigin#24279) Arena-allocate all `PhyOperator` nodes and child-pointer slices from two pre-sized slices instead of individual heap allocations per operator. This reduces GC pressure in `ConvertOperatorToPhyOperator` which runs post-execution for every statement that needs EXPLAIN ANALYZE output. ### Changes - Introduce `phyOpArena` struct holding a single `[]PhyOperator` node slice and a single `[]*PhyOperator` child-pointer slice, both pre-allocated to exact capacity via `countOperators`. - All nodes are appended into the arena; child pointer slices are sub-sliced from the shared buffer. For a 50-operator query, this reduces ~150 heap allocations to ~4. - `getDestReceiver` now returns `nil` for the common case (non-Connector/non-Dispatch operators) instead of allocating an empty slice every time. - Cache `op.GetOperatorBase()` in a local variable to avoid repeated interface dispatch. ### Impact - For prepared statements: zero regression — the PhyOperator tree is built once and reused via `UpdatePreparePhyOperator` which does in-place pointer updates with no allocations. - For ad-hoc statements: one `countOperators` tree walk added (cheap pointer chase over hot cache lines), but eliminates N-1 `make` calls and N `new`-equivalent allocations. - JSON serialization format unchanged — `Children []*PhyOperator` still serializes as a nested tree. Approved by: @ouyuanning
1 task done
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
…trixorigin#24279) Arena-allocate all `PhyOperator` nodes and child-pointer slices from two pre-sized slices instead of individual heap allocations per operator. This reduces GC pressure in `ConvertOperatorToPhyOperator` which runs post-execution for every statement that needs EXPLAIN ANALYZE output. ### Changes - Introduce `phyOpArena` struct holding a single `[]PhyOperator` node slice and a single `[]*PhyOperator` child-pointer slice, both pre-allocated to exact capacity via `countOperators`. - All nodes are appended into the arena; child pointer slices are sub-sliced from the shared buffer. For a 50-operator query, this reduces ~150 heap allocations to ~4. - `getDestReceiver` now returns `nil` for the common case (non-Connector/non-Dispatch operators) instead of allocating an empty slice every time. - Cache `op.GetOperatorBase()` in a local variable to avoid repeated interface dispatch. ### Impact - For prepared statements: zero regression — the PhyOperator tree is built once and reused via `UpdatePreparePhyOperator` which does in-place pointer updates with no allocations. - For ad-hoc statements: one `countOperators` tree walk added (cheap pointer chase over hot cache lines), but eliminates N-1 `make` calls and N `new`-equivalent allocations. - JSON serialization format unchanged — `Children []*PhyOperator` still serializes as a nested tree. Approved by: @ouyuanning
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
…trixorigin#24279) Arena-allocate all `PhyOperator` nodes and child-pointer slices from two pre-sized slices instead of individual heap allocations per operator. This reduces GC pressure in `ConvertOperatorToPhyOperator` which runs post-execution for every statement that needs EXPLAIN ANALYZE output. ### Changes - Introduce `phyOpArena` struct holding a single `[]PhyOperator` node slice and a single `[]*PhyOperator` child-pointer slice, both pre-allocated to exact capacity via `countOperators`. - All nodes are appended into the arena; child pointer slices are sub-sliced from the shared buffer. For a 50-operator query, this reduces ~150 heap allocations to ~4. - `getDestReceiver` now returns `nil` for the common case (non-Connector/non-Dispatch operators) instead of allocating an empty slice every time. - Cache `op.GetOperatorBase()` in a local variable to avoid repeated interface dispatch. ### Impact - For prepared statements: zero regression — the PhyOperator tree is built once and reused via `UpdatePreparePhyOperator` which does in-place pointer updates with no allocations. - For ad-hoc statements: one `countOperators` tree walk added (cheap pointer chase over hot cache lines), but eliminates N-1 `make` calls and N `new`-equivalent allocations. - JSON serialization format unchanged — `Children []*PhyOperator` still serializes as a nested tree. Approved by: @ouyuanning
VioletQwQ-0
pushed a commit
to VioletQwQ-0/matrixone
that referenced
this pull request
Sep 17, 2026
…trixorigin#24279) Arena-allocate all `PhyOperator` nodes and child-pointer slices from two pre-sized slices instead of individual heap allocations per operator. This reduces GC pressure in `ConvertOperatorToPhyOperator` which runs post-execution for every statement that needs EXPLAIN ANALYZE output. ### Changes - Introduce `phyOpArena` struct holding a single `[]PhyOperator` node slice and a single `[]*PhyOperator` child-pointer slice, both pre-allocated to exact capacity via `countOperators`. - All nodes are appended into the arena; child pointer slices are sub-sliced from the shared buffer. For a 50-operator query, this reduces ~150 heap allocations to ~4. - `getDestReceiver` now returns `nil` for the common case (non-Connector/non-Dispatch operators) instead of allocating an empty slice every time. - Cache `op.GetOperatorBase()` in a local variable to avoid repeated interface dispatch. ### Impact - For prepared statements: zero regression — the PhyOperator tree is built once and reused via `UpdatePreparePhyOperator` which does in-place pointer updates with no allocations. - For ad-hoc statements: one `countOperators` tree walk added (cheap pointer chase over hot cache lines), but eliminates N-1 `make` calls and N `new`-equivalent allocations. - JSON serialization format unchanged — `Children []*PhyOperator` still serializes as a nested tree. Approved by: @ouyuanning
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 type of PR is this?
Which issue(s) this PR fixes:
Fixes #21116
What this PR does / why we need it:
Arena-allocate all
PhyOperatornodes and child-pointer slices from two pre-sized slices instead of individual heap allocations per operator. This reduces GC pressure inConvertOperatorToPhyOperatorwhich runs post-execution for every statement that needs EXPLAIN ANALYZE output.Changes
phyOpArenastruct holding a single[]PhyOperatornode slice and a single[]*PhyOperatorchild-pointer slice, both pre-allocated to exact capacity viacountOperators.getDestReceivernow returnsnilfor the common case (non-Connector/non-Dispatch operators) instead of allocating an empty slice every time.op.GetOperatorBase()in a local variable to avoid repeated interface dispatch.Impact
UpdatePreparePhyOperatorwhich does in-place pointer updates with no allocations.countOperatorstree walk added (cheap pointer chase over hot cache lines), but eliminates N-1makecalls and Nnew-equivalent allocations.Children []*PhyOperatorstill serializes as a nested tree.Test plan
pkg/sql/models/...)🤖 Generated with Claude Code