Skip to content

refactor(cuda): simplify benchmark session setup (#10885) - #10885

Merged
0ax1 merged 2 commits into
developfrom
ad/cuda-bench-sessions
Nov 6, 2026
Merged

0ax1 merged 2 commits into
developfrom
ad/cuda-bench-sessions

Conversation

@0ax1

@0ax1 0ax1 commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Simplifies session setup in seven CUDA benchmarks by removing explicit
registration of default host session variables.

VortexSession already initializes these variables with the same defaults
on first access. Register only CudaSession explicitly, preserving the
custom FSST export-layout configuration.

Changes

  • Remove redundant ArraySession, KernelSession, DTypeSession,
    ScalarFnSession, AggregateFnSession, and MemorySession registrations.
  • Remove the corresponding imports.
  • Keep CUDA session configuration unchanged.

This is benchmark setup cleanup, not a decoding optimization. Host
session defaults are initialized on first use rather than eagerly.
Production code is unaffected.

No builds, tests, or benchmarks were run for this change.

@0ax1 0ax1 added the changelog/chore A trivial change label Oct 27, 2026
@0ax1

0ax1 commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

@claude review this pr in depth

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @0ax1's task in 1m 38s —— View job


Review of #10885

Verdict: LGTM. The change preserves behaviour: the new sessions act the same as the old ones. I found nothing blocking, only two optional cleanups.

  • Read the diff (7 bench files, +17/−114)
  • Check VortexSession::get / get_opt behaviour in vortex-session
  • Look for code paths that would act differently when a variable is missing rather than registered
  • Check how the benches use the sessions (SESSION vs cuda_session())
  • Post review

Why the sessions behave the same

  • VortexSession::with::<V>() is just with_some(V::default()) (vortex-session/src/session.rs:209).
  • SessionExt::get::<V>() inserts the same V::default() on first access (session.rs:252-258).
  • A missing variable is only observable through get_opt, which never inserts a default. I searched the workspace for every get_opt call:
    • The only one that touches the removed types is vortex_array::initialize (vortex-array/src/lib.rs:148). It skips arrays::initialize when no KernelSession is present.
    • None of the changed benches call initialize or register arrays or kernels.
    • Its doc comment says KernelSession::default already includes the built-in kernels. So when get later creates the default KernelSession, the kernels are there anyway.
    • The other get_opt calls (MultiFileSession, EnabledEditions, UnknownPluginPolicy) don't involve the removed types.
  • CudaSession::try_default() (vortex-cuda/src/session.rs:133) builds the CUDA context and runs initialize_cuda on itself. It never reads the outer VortexSession, so the order in which variables are registered doesn't matter.
  • There is precedent for this pattern: the crate's own cuda_session() helper (vortex-cuda/src/lib.rs:155) and many unit tests (static SESSION = LazyLock::new(VortexSession::empty)) already rely on defaults being created on first use.

Performance note

The PR description is accurate:

  • In alp, bitpacked, delta, dynamic_dispatch and for, SESSION is only used for CPU-side setup, outside the timed closures.
  • In arrow_validity (CudaSession::create_execution_ctx(&SESSION) inside iter_custom) and fsst (VARBIN_SESSION / VARBINVIEW_SESSION), the first lazy insert is a single copy-on-write map clone per type. It only happens once, during warm-up, so measured iterations are unaffected.

Compile and format checks (by reading the code)

  • No imports are left unused. LazyLock, VortexSession and CudaSession are still used in every file, and VortexExpect is still used in fsst_cuda.rs.
  • The wrapped static SESSION: LazyLock<VortexSession> =\n LazyLock::new(...) is correct rustfmt output. The single-line form would be about 104 columns, over the 100-column limit.

Optional cleanups (not blocking)

  1. SESSION now duplicates vortex_cuda::cuda_session(). After this change, the static in six benches (alp, arrow_validity, bitpacked, delta, dynamic_dispatch, for) is exactly what cuda_session() builds (vortex-cuda/src/lib.rs:154-156, available to benches through the _test-harness dev-dependency feature). It could be:

    static SESSION: LazyLock<VortexSession> = LazyLock::new(vortex_cuda::cuda_session);

    That keeps one definition of "the bench session" and drops the CudaSession import in files that use it only here. Fix this →

  2. The doc comment on cuda_session() is out of date. It says it builds a session "with all array session variables plus a default CudaSession" (vortex-cuda/src/lib.rs:144-145), but it only registers CudaSession; the array variables are created on first use. This file isn't in the diff, but this PR applies the same reasoning, so it's a natural place to fix the wording, e.g. "with a default CudaSession; array session variables are created with their defaults on first use".

A follow-up outside this PR's scope: in five of the six benches (all but arrow_validity), SESSION is only ever used through SESSION.create_execution_ctx(), a CPU context. Registering a CudaSession there creates an extra CUDA context and stream pool at startup (LazyLock::force(&SESSION) in main) that the bench never uses. A plain VortexSession::empty() would be enough, unless forcing CUDA initialisation early is intentional.

Checks

I didn't build, lint or run the benches. Following CLAUDE.md, I left verification to CI and the maintainer, and running the CUDA benches needs a GPU anyway. Everything above comes from reading the code.

@codspeed

codspeed Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

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

✅ 1964 untouched benchmarks


Comparing ad/cuda-bench-sessions (336e223) with develop (082f2da)

Open in CodSpeed

@0ax1
0ax1 force-pushed the ad/cuda-bench-sessions branch from 0b63c70 to f6ee1d6 Compare November 4, 2026 13:27
@0ax1 0ax1 changed the title refactor(cuda): stop registering default session variables in benches refactor(cuda): simplify benchmark session setup (#10885) Nov 4, 2026
@0ax1
0ax1 marked this pull request as ready for review November 4, 2026 13:36
@0ax1
0ax1 requested review from mprammer and robert3005 November 4, 2026 13:36
0ax1 added 2 commits November 6, 2026 09:11
that register `ArraySession`, `KernelSession`, `DTypeSession`,
`ScalarFnSession`, `AggregateFnSession` and `MemorySession` up front,
although `VortexSession::empty()` creates each of them with the same
defaults on first use. Register only the `CudaSession`.

Signed-off-by: Alexander Droste <alexander.droste@protonmail.com>
Signed-off-by: Alexander Droste <alexander.droste@protonmail.com>
@0ax1
0ax1 force-pushed the ad/cuda-bench-sessions branch from d2a402f to 336e223 Compare November 6, 2026 08:11
@0ax1
0ax1 enabled auto-merge (squash) November 6, 2026 08:13
@0ax1
0ax1 merged commit 2c3c510 into develop Nov 6, 2026
70 checks passed
@0ax1
0ax1 deleted the ad/cuda-bench-sessions branch November 6, 2026 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/chore A trivial change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants