Skip to content

Remove usages of LEGACY_SESSION from tests#8547

Merged
robert3005 merged 8 commits into
developfrom
rk/nolegacysession
Jun 23, 2026
Merged

Remove usages of LEGACY_SESSION from tests#8547
robert3005 merged 8 commits into
developfrom
rk/nolegacysession

Conversation

@robert3005

Copy link
Copy Markdown
Contributor

Continuing migration away from deprecated methods

Signed-off-by: Robert Kruszewski <github@robertk.io>
@robert3005 robert3005 requested a review from a team June 23, 2026 08:50
@robert3005 robert3005 added the changelog/chore A trivial change label Jun 23, 2026
@0ax1 0ax1 self-requested a review June 23, 2026 08:52
Signed-off-by: Robert Kruszewski <github@robertk.io>
@robert3005 robert3005 enabled auto-merge (squash) June 23, 2026 08:55
@codspeed-hq

codspeed-hq Bot commented Jun 23, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

⚡ 3 improved benchmarks
❌ 1 regressed benchmark
✅ 1579 untouched benchmarks

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation slice_empty_vortex 310 ns 368.3 ns -15.84%
Simulation bitwise_not_vortex_buffer_mut[128] 215.3 ns 186.1 ns +15.67%
Simulation bitwise_not_vortex_buffer_mut[1024] 275.6 ns 246.4 ns +11.84%
Simulation eq_i64_constant 318.6 µs 289 µs +10.23%

Tip

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


Comparing rk/nolegacysession (ae828f6) with develop (40a7857)

Open in CodSpeed

@0ax1

0ax1 commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

@claude review in depth

@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Claude finished @0ax1's task in 2m 51s —— View job


Claude in-depth PR review

  • Gather context (diff, commits)
  • Understand the LEGACY_SESSIONarray_session()/SESSION migration
  • Review correctness of the replacements
  • Spot-check non-mechanical changes (pco, test_harness, duckdb)
  • Post review

Summary

This PR mechanically migrates test code off the deprecated LEGACY_SESSION static, replacing LEGACY_SESSION.create_execution_ctx() with either array_session().create_execution_ctx() or a crate-local SESSION. The change is semantically sound: LEGACY_SESSION is defined as

pub static LEGACY_SESSION: LazyLock<VortexSession> = LazyLock::new(array_session);

so array_session() produces an equivalent (fresh, fully-registered) session. I could not run cargo/clippy in this environment (sandbox denies build commands), but static analysis looks clean and the change is approved + green on CodSpeed.

What I verified

  • Semantic equivalence. Every migrated call site previously got a session built by array_session() via the lazy static; it now calls array_session() directly. Same registries (arrays, dtypes, scalar/aggregate fns, stats, kernels, arrow, memory).
  • Imports. Files that switched to array_session() add use …::array_session; and drop the now-unused LEGACY_SESSION import (e.g. vortex-duckdb/src/convert/vector.rs:405, vortex-array/src/validity.rs, vortex/src/lib.rs:200). Files that still use LEGACY_SESSION in production paths correctly keep their top-level import while only the mod test block migrates (e.g. vortex-array/src/arrays/dict/array.rs, encodings/fsst/src/array.rs).
  • pco change is an improvement, not just a swap. encodings/pco/src/tests.rs replaces LEGACY_SESSION.arrow() with a local SESSION (tests.rs:33-37) that registers the Pco encoding on top of array_session(). That's more correct for execute_arrow on a Pco array, since LEGACY_SESSION does not have Pco registered.
  • Scope matches the title. The 70 files still referencing LEGACY_SESSION are non-test/production paths (FFI, CUDA, cxx, compat-gen, builders, vtables, benches) — consistent with "from tests".

Minor observations (non-blocking)

  1. array_session() per-call cost in shared test harness helpers. Two files migrated are not #[cfg(test)] modules but always-compiled (feature-gated) helpers:

    • vortex-array/src/test_harness.rs:33 (to_int_indices)
    • vortex-array/src/arrays/bool/test_harness.rs:18,33 (BoolArray::true_count/false_count)

    Each invocation now constructs a brand-new VortexSession with all 8 registries, whereas LEGACY_SESSION amortized that behind a LazyLock. If any of these helpers are called in tight loops, the per-call session build adds overhead. It's test-only (CodSpeed shows a net improvement, so no real regression), but if you want to preserve the amortization you could keep a module-local static SESSION: LazyLock<VortexSession> = LazyLock::new(array_session); in those harness files. Purely optional.

  2. Consistency of replacement target. Most sites use array_session(); a few crates introduce a local SESSION static. Both are fine, but where a crate already has (or needs) a customized session like pco, prefer the local SESSION so the encoding under test is registered.

Verdict

Clean, low-risk, mechanical migration with one genuine correctness improvement (pco). No bugs found. The only thing worth a second look is the per-call session construction in the always-compiled test_harness.rs helpers, and even that is negligible for test code.

Note: I was unable to run cargo +nightly fmt --check, cargo clippy, or cargo nextest here (build commands are not permitted in this review sandbox) — please rely on CI for the formatting/lint/test gates.
· rk/nolegacysession

@0ax1

0ax1 commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

@claude what about perf implications, and creating sessions in a tight loop

@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

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


Perf implications & session creation in tight loops

Good question — I traced every migrated call site and the session-construction cost. Short version: no production impact, and the genuinely hot loops were deliberately left on amortized statics. One narrow class of test-only helpers does now build a session per call.

What array_session() costs per call

create_execution_ctx() does two things:

// vortex-array/src/executor.rs:850
fn create_execution_ctx(&self) -> ExecutionCtx { ExecutionCtx::new(self.clone()) }

// executor.rs:335 — clones the session + snapshots the execute-parent kernel registry
pub fn new(session: VortexSession) -> Self {
    let execute_parent_kernels = session.kernels_opt()
        .map(|k| k.execute_parent_snapshot()).unwrap_or_default();
    ...
}

The session clone + kernel snapshot happened per call under LEGACY_SESSION too — that part is unchanged. The new cost is only the 8-registry build in array_session() (lib.rs:107: arrays, kernels, dtypes, scalar fns, stats, aggregate fns, arrow, memory) that LEGACY_SESSION's LazyLock used to amortize to once-per-process.

Production paths: zero impact

Every migrated site is test-gated. test_harness.rs is #[cfg(any(test, feature = "_test-harness"))] (lib.rs:79), bool/test_harness.rs is #[cfg(feature = "_test-harness")] (bool/mod.rs:22), everything else is in #[cfg(test)] mod tests. LEGACY_SESSION itself is kept for the real back-compat production path (the TODO(ngates) at lib.rs:120). So no shipped code changed.

Tight loops: the hot ones were not migrated

This is the key point for your question. The fuzz crate is the one place with genuine tight loops, and its hot paths still use a crate-local amortized LazyLock static, not array_session():

// fuzz/src/lib.rs:50
pub static SESSION: LazyLock<VortexSession> = LazyLock::new(|| { ... });

// fuzz/src/array/mod.rs:188 / :557 / :574 / :589 / :754  (execute, compress, compare loops)
let mut ctx = SESSION.create_execution_ctx();

Only the #[cfg(test)] unit tests in fuzz/src/array/mask.rs and fill_null.rs call array_session() per call — and those run once per test, not in a loop. So the migration correctly distinguished "loop → keep amortized static" from "single test → fresh session is fine." That's also consistent with CodSpeed reporting +11.74% / no regressions.

The one thing actually worth a look

The two always-compiled (feature-gated, not #[cfg(test)]) harness helpers now build a full session on every call:

  • vortex-array/src/test_harness.rs:33to_int_indices() (called from e.g. scalar_fn/fns/between)
  • vortex-array/src/arrays/bool/test_harness.rs:18,33BoolArray::opt_bool_vec() / bool_vec()

If any test invokes one of these inside an inner loop, each iteration pays a fresh 8-registry build that LEGACY_SESSION previously amortized. It's test-only and CodSpeed shows a net win, so this is non-blocking — but if you want to preserve the amortization, restore a module-local static in those two files:

use std::sync::LazyLock;
static SESSION: LazyLock<VortexSession> = LazyLock::new(array_session);
// ... &mut SESSION.create_execution_ctx()

Fix this →

Bottom line

  • Production: unaffected — all changes are test/feature-gated.
  • Tight loops: the fuzz hot loops keep the amortized SESSION static; per-call array_session() only appears in one-shot #[cfg(test)] tests. No perf regression there.
  • Minor: the two _test-harness helpers lost their amortization; harmless unless called in an inner loop. Optional one-line fix above.
    · rk/nolegacysession

Signed-off-by: Robert Kruszewski <github@robertk.io>
@robert3005 robert3005 disabled auto-merge June 23, 2026 10:30
Signed-off-by: Robert Kruszewski <github@robertk.io>
Signed-off-by: Robert Kruszewski <github@robertk.io>
Signed-off-by: Robert Kruszewski <github@robertk.io>
Signed-off-by: Robert Kruszewski <github@robertk.io>
@robert3005 robert3005 enabled auto-merge (squash) June 23, 2026 10:41
Signed-off-by: Robert Kruszewski <github@robertk.io>
@robert3005 robert3005 merged commit 226477d into develop Jun 23, 2026
62 of 63 checks passed
@robert3005 robert3005 deleted the rk/nolegacysession branch June 23, 2026 11:21
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