Skip to content

perf(executor): per-ExecutionCtx ArrayKernels snapshot#61

Merged
lukekim merged 1 commit into
spiceai-53from
lukim/exec-kernel-snapshot
Jun 12, 2026
Merged

perf(executor): per-ExecutionCtx ArrayKernels snapshot#61
lukekim merged 1 commit into
spiceai-53from
lukim/exec-kernel-snapshot

Conversation

@lukekim

@lukekim lukekim commented Jun 12, 2026

Copy link
Copy Markdown

What

Resolves ArrayKernels once at ExecutionCtx construction into a crate-private KernelSnapshot (a single ArcSwap::load_full of the execute-parent kernel map), instead of cloning the session and probing the sharded session-variable DashMap on every array node in the execute_until / single-step execution paths.

Why

  • Removes a per-array-node session clone + DashMap shard RwLock probe from the hot execution loop.
  • Stops holding the session-variable read guard across kernel invocation (previously a plugin kernel touching the session registry could contend/deadlock on the same shard).

Semantics

The registry is session-scoped and mutable via its public register_* methods. An ExecutionCtx sees a point-in-time snapshot taken at construction; later registrations are picked up by the next context (contexts are created per evaluation, e.g. create_execution_ctx() per filter/projection evaluation). Kernel lookup order is unchanged: registered plugin kernels are tried before static execute_parent kernels, with the same (parent, child) hashing.

KernelSnapshot and ArrayKernels::snapshot() are pub(crate) — no new public API.

Testing

  • cargo nextest run -p vortex-array — 2789 passed (includes struct_cast_execute_parent_uses_session_plugin, which registers a plugin kernel and then executes through a fresh ctx, covering the register → snapshot → execute path).
  • cargo clippy --all-targets -p vortex-array — no diagnostics in changed files.

Split out of #60 (first of two independent changes).

Resolve ArrayKernels once at ExecutionCtx construction into a KernelSnapshot
(an ArcSwap::load_full of the execute-parent kernel map) instead of cloning
the session and probing the sharded session-variable DashMap on every array
node in the execute_until / single-step paths. This also stops holding the
session-variable read guard across kernel invocation.

The registry is session-scoped and mutable via its public register_* methods:
an ExecutionCtx sees a point-in-time snapshot taken at construction, and
later registrations are picked up by the next context (contexts are created
per evaluation). KernelSnapshot and ArrayKernels::snapshot() are pub(crate),
so no new public API is added.

Signed-off-by: Luke Kim <80174+lukekim@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 12, 2026 20:41
@lukekim lukekim added the changelog/performance A performance improvement label Jun 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR optimizes the vortex-array execution hot path by taking a point-in-time snapshot of session-scoped ArrayKernels execute-parent registrations at ExecutionCtx construction, avoiding repeated session-variable lookups and lock probing during execute_until and single-step execution.

Changes:

  • Added ArrayKernels::snapshot() and a crate-private KernelSnapshot to capture the current execute-parent kernel registry via a single ArcSwap::load_full().
  • Cached Option<KernelSnapshot> inside ExecutionCtx, and updated execute-parent dispatch to consult the snapshot instead of re-reading from the session per array node.
  • Updated internal execute-parent helper signatures to accept Option<&KernelSnapshot>.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
vortex-array/src/optimizer/kernels.rs Introduces KernelSnapshot and ArrayKernels::snapshot() to capture execute-parent kernels as an owned Arc without copying the map.
vortex-array/src/executor.rs Caches the snapshot in ExecutionCtx and routes execute-parent plugin lookup through the cached snapshot to avoid repeated session probes/locks.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lukekim
lukekim merged commit ccaa556 into spiceai-53 Jun 12, 2026
27 of 56 checks passed
@lukekim
lukekim deleted the lukim/exec-kernel-snapshot branch June 12, 2026 22:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/performance A performance improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants