Skip to content

Guard active parent builders and reattach slots in Executor Step 2a - #12316

Open
lwwmanning wants to merge 4 commits into
developfrom
wm/fix-executor-parent-builder-guard
Open

lwwmanning wants to merge 4 commits into
developfrom
wm/fix-executor-parent-builder-guard

Conversation

@lwwmanning

@lwwmanning lwwmanning commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

This fixes Step 2a of the iterative executor (ArrayRef::execute_until in vortex-array), where execute-parent kernels run against the parent that ExecuteSlot suspended. Steps 1b and 2b are unchanged.

On develop, Step 2a checks only whether the current array has an active builder. It ignores a builder that the suspended parent left in its frame. A parent rewrite can then lose or duplicate data that AppendChild already appended. Step 2a also gives kernels the parent with the child slot still detached (None), and a rewrite does not inherit the parent's statistics.

With this PR, Step 2a also skips when the suspended frame has a parent_builder. If the session has a kernel for the parent and child encodings, Step 2a puts the child back into its slot first. If they all decline, it detaches the child again, as Step 1b does. A rewrite now inherits the parent's statistics, as in Steps 1b and 2b.

The PR also turns executor.rs into executor/mod.rs, moves the existing executor tests into executor/tests.rs, and adds two regression tests there. The test kernel in the trace harness now asserts that the slot is attached, and the execution guide in docs/ describes the new Step 2a.

Assisted by Antigravity.

Skip Step 2a (stack_execute_parent) in ArrayRef::execute_until when the suspended parent frame has an active parent_builder, matching Step 1b so parent kernels do not rewrite partially consumed builder state.

When Step 2a probes registered execute-parent kernels, temporarily reattach the focused child into the suspended parent slot before calling the kernel and detach it again if all kernels decline, ensuring parent kernels never observe a None slot hole.

Update StackParentKernel in the trace test harness, which previously relied on the detached None slot to distinguish Step 2a from Step 2b, and add regression tests for both invariants.

Signed-off-by: Will Manning <will@willmanning.io>
@lwwmanning lwwmanning added the changelog/fix A bug fix label Nov 29, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-29T13:56:06.878045Z 922fd2e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@codspeed

codspeed Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 5.29%

Warning

vortex-data has exceeded the Hobby plan limit of 5 active contributors. Upgrade your plan or apply to the open source program by December 8, 2026 to keep using CodSpeed.

1 warning

⚠️ Walltime results may be unreliable

Some benchmarks used the Walltime instrument outside CodSpeed Macro Runners, which can make the results inconsistent.

Learn more about Macro Runners

See affected benchmarks

⚡ 1 improved benchmark
❌ 3 regressed benchmarks
✅ 2173 untouched benchmarks
⏩ 164 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ CPU Simulation repeated[patched] 210.7 µs 241.8 µs -12.86%
❌ CPU Simulation once[patched] 164.1 µs 187.3 µs -12.4%
❌ CPU Simulation patched_same_lane_once 203.1 µs 226.5 µs -10.33%
⚡ CPU Simulation varbinview_large 153.6 µs 130.7 µs +17.56%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing wm/fix-executor-parent-builder-guard (ef6cd42) with develop (4525dfa)

Open in CodSpeed

Footnotes

  1. 164 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. ↩

Signed-off-by: Will Manning <will@spiraldb.com>
Co-Authored-By: Will Manning <will@spiraldb.com>
devin-ai-integration[bot]

This comment was marked as resolved.

Signed-off-by: Will Manning <will@spiraldb.com>
Co-Authored-By: Will Manning <will@spiraldb.com>

@lwwmanning lwwmanning left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Posted by Claude Opus 5.5 on Will's behalf.

CodSpeed reports three patched benchmarks in vortex-array/benches/probe.rs as 10% to 13% slower: repeated[patched], once[patched] and patched_same_lane_once. The other five PRs opened at the same time do not show this. This PR changes the executor loop, so I don't think it is noise.

My guess is the new Step 2a path. When a kernel exists for the parent and child pair, each iteration pops the frame and puts the child back into the parent. If the kernel declines, it takes the child out again. If something else holds the parent, the put may also copy it. A patched array whose parent kernel declines would pay this on every step. Could you profile one of these benchmarks to confirm the cause before this merges?

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Checked vortex-array/benches/probe.rs and the compiled release bench binary (ef6cd4276 vs develop 4525dfaac):

  • once[patched], repeated[patched], and patched_same_lane_once do not enter ArrayRef::execute_until or Step 2a at all. The patched() fixture is non-nullable with four PrimitiveArray slots (inner, lane_offsets, patch_indices, patch_values), so execute_scalar dispatches directly to <Patched as OperationsVTable<Patched>>::probe_scalar → Primitive::probe_scalar.
  • Verified via objdump -d on the release bench binary that <Patched as OperationsVTable<Patched>>::probe_scalar makes no calls into executor. Its code size is slightly smaller on HEAD (0x1491 vs 0x14af), while its address shifted (0xd75020 vs 0x37d580) due to promoting executor.rs to executor/mod.rs and changing execute_until, which shifts code layout in CodSpeed's cache simulation.
  • Local cargo bench -p vortex-array --bench probe -- "patched" medians (100 samples × 100 iters) show no slowdown on once[patched] (11.32 µs vs 11.30 µs) or patched_same_lane_once (15.17 µs vs 15.69 µs), and 14.23 µs vs 13.33 µs on repeated[patched]. None of the 2,173 other CodSpeed benchmarks (including executor benchmarks) regressed.

@lwwmanning lwwmanning left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by Gemini 4 Carbon on behalf of @lwwmanning.

The Step 2a changes in vortex-array/src/executor/mod.rs are right and bring stack_execute_parent into parity with Steps 1b and 2b. Three cleanups before merging:

  1. Remove the inaccurate CodSpeed regression claim from the PR description:
    • The PR description states: "On CodSpeed, three probe benchmarks on patched arrays are 10% to 13% slower, possibly because of the slot reattach." probe.rs never enters execute_until (and PR #12099 hit the identical 241.8 / 187.4 / 226.5 µs numbers without touching executor, confirming Cachegrind I-cache layout noise). Since PR descriptions become the squash commit message, please remove that sentence.
  2. Collapse the 495 lines of mock VTable boilerplate in vortex-array/src/executor/tests.rs:
    • Defining four separate custom VTables (StepChild, ReadyChild, BuilderParent, SlotInspectParent) plus UnitArrayData (duplicating crate::array::EmptyArrayData) is ~330 lines more boilerplate than these two tests need:
      • Use a single TestChild (TestValuesData { values: PrimitiveArray }): in ForbiddenBuilderParentKernel, return Ok(None) while parent.slots()[0].is_some() (declining Step 2b before AppendChild(0) runs, so any call with parent.slots()[0].is_none() proves Step 2a fired with an active parent_builder); in InspectSlotParentKernel, use seen_once: AtomicBool (matching StackParentKernel in vortex-array/src/test_harness/trace/tests.rs) so it declines Step 2b once, suspends via ExecuteSlot, and runs in Step 2a.
      • Merge BuilderParent and SlotInspectParent into a single TestParent VTable backed by crate::array::EmptyArrayData (ValidityVTableFromChild reading array.slots().last()): with 1 slot ([Some(child)]), execute slot 0 via ExecuteSlot(0) without a builder; with 2 slots ([Some(first), Some(second)]), AppendChild(0) -> ExecuteSlot(1) -> AppendChild(1).
  3. Update stale comment in vortex-array/src/arrays/runend/rules.rs:
    • Update line 113 (// During execution the current child can be detached from its parent.) in supports_run_values, since Step 2a now reattaches the active child slot before invoking ExecuteParentKernels.

Signed-off-by: Will Manning <will@spiraldb.com>
Co-Authored-By: Will Manning <will@spiraldb.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor

Addressed all three items in 660b6fe80 and the PR description:

  1. Removed the inaccurate CodSpeed sentence from the PR description.
  2. Collapsed the mock VTables in vortex-array/src/executor/tests.rs into a single TestChild and TestParent backed by EmptyArrayData.
  3. Removed the stale detached-child comment in vortex-array/src/arrays/runend/rules.rs.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 new potential issue.

Devin Review

Comment thread vortex-array/src/executor/tests.rs Resolved

This branch was successfully deployed

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

Labels

changelog/fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant