Refactor validity checks to require explicit ExecutionCtx#8273
Open
joseph-isaacs wants to merge 4 commits into
Open
Refactor validity checks to require explicit ExecutionCtx#8273joseph-isaacs wants to merge 4 commits into
joseph-isaacs wants to merge 4 commits into
Conversation
`Validity::is_valid`/`is_null` previously created an internal `LEGACY_SESSION` execution context to evaluate the validity array. Replace them with `execute_is_valid`/`execute_is_null` that accept an `&mut ExecutionCtx` from the caller, threading the context through where one is available and falling back to a `LEGACY_SESSION` context only at boundaries that do not yet have one. Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
Keep the original ctx-free `is_valid`/`is_null` methods for backward compatibility, marked `#[deprecated]`, delegating to the new `execute_is_valid`/`execute_is_null` via a `LEGACY_SESSION` context. Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
Merging this PR will improve performance by 18.36%
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | Simulation | bitwise_not_vortex_buffer_mut[128] |
275.3 ns | 216.9 ns | +26.89% |
| ⚡ | Simulation | rebuild_naive |
141.9 µs | 113.7 µs | +24.84% |
| ⚡ | Simulation | bitwise_not_vortex_buffer_mut[1024] |
336.9 ns | 278.6 ns | +20.94% |
| ⚡ | Simulation | extend_from_array_non_zctl_overlapping[(10000, 8)] |
4.7 ms | 4 ms | +18.44% |
| ⚡ | Simulation | bitwise_not_vortex_buffer_mut[2048] |
400.6 ns | 342.2 ns | +17.05% |
| ⚡ | Simulation | extend_from_array_non_zctl_overlapping[(1000, 8)] |
527.8 µs | 453.8 µs | +16.3% |
| ⚡ | Simulation | extend_from_array_zctl[(10000, 8)] |
2.5 ms | 2.2 ms | +12.73% |
| ⚡ | Simulation | extend_from_array_zctl[(1000, 8)] |
290.9 µs | 263 µs | +10.61% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing claude/eager-cerf-Sj3pp (dbb16c1) with develop (e06d80b)
Consolidate the validity/scalar checks in the tests updated by the `execute_is_valid` migration so each test creates one execution context and reuses it, instead of constructing a fresh `LEGACY_SESSION` context per call (some inside loops). Also unify the ALP sliced-vector test on a single `SESSION` context for both encode and execute, rather than mixing `SESSION` and `LEGACY_SESSION`. Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
…ation `VarBinViewArray`/`VarBinArray` validation only needs an execution context when validity is array-backed. Previously `is_null` short-circuited for the `NonNullable`/`AllValid` variants without ever creating a context, but the ctx-threaded version constructed a `LEGACY_SESSION` context unconditionally, adding overhead to the common non-null construction path (observed as a regression in the `varbinview_zip` benchmarks). Construct the context lazily, only for `Validity::Array`, and resolve the constant variants without one. The UTF-8 validation loop is extracted into `VarBinArray::validate_utf8` with an `is_null_at` helper to keep the function within the cognitive-complexity budget. Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
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.
Summary
This PR refactors the
ValidityAPI to require an explicitExecutionCtxparameter for validity checks, improving execution context management and making it explicit where execution happens.Changes
New execution-aware methods in
Validity:execute_is_valid(index, ctx)- checks if an element is valid using the provided contextexecute_is_null(index, ctx)- checks if an element is null using the provided contextDeprecated legacy methods:
is_valid(index)as deprecated in favor ofexecute_is_validis_null(index)as deprecated in favor ofexecute_is_nullLEGACY_SESSION