Skip to content

Move kernel logic out of dispatch macros in small crates - #11525

Merged
joseph-isaacs merged 11 commits into
developfrom
ji/mutants-macros-small-crates
Nov 17, 2026
Merged

joseph-isaacs merged 11 commits into
developfrom
ji/mutants-macros-small-crates

Conversation

@joseph-isaacs

@joseph-isaacs joseph-isaacs commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

cargo-mutants can't mutate code inside macros, so logic in match_each_*! bodies is never mutation tested. This moves that logic into small generic helpers in elias-fano, bytebool, row, sequence, arrow, layout and onpair, and documents the rule in vortex-array/src/dtype/AGENTS.md.

🤖 Generated with Claude Code

https://claude.ai/code/session_01UeniBAvrcuvbZMgsM2XrTM

joseph-isaacs and others added 9 commits November 17, 2026 10:47
cargo-mutants does not mutate code inside macro invocations, so the unary
encode loop written inside the `match_each_unsigned_integer_ptype!` body in
`unary_encode` was invisible to mutation testing.

Move the loop that writes each value in unary into a private generic
`unary_bits<T>` function, leaving the macro as a thin dispatch that resolves
`T` and calls it. `Unary::try_new` now runs after the dispatch, since it does
not depend on `T`. Behavior and monomorphization are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UeniBAvrcuvbZMgsM2XrTM
Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
cargo-mutants does not mutate code inside macro invocations, so the take
gather written inside the `match_each_integer_ptype!` body in
`<ByteBool as TakeExecute>::take` was invisible to mutation testing.

Move the masked/unmasked gather and the out-of-bounds panic into a private
generic `take_bytes_into<I>` function, leaving the macro as a thin dispatch
that resolves `I` and calls it. Behavior and monomorphization are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UeniBAvrcuvbZMgsM2XrTM
Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
cargo-mutants cannot mutate code inside macro invocations, so logic in a
`match_each_*!` body is never mutation tested. Add the rule to the
top-level AGENTS.md and the details, with an example, to a new
vortex-array/AGENTS.md next to where the dispatch macros are defined.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UeniBAvrcuvbZMgsM2XrTM
Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
cargo-mutants does not mutate code inside macro invocations, so the
offset and size conversion loops written inside the
`match_each_integer_ptype!` bodies in `list_ranges` were never mutation
tested. Move that loop into a private generic `values_to_usize` helper
and leave the macro calls as thin dispatch. The helper monomorphizes to
the same code and performs the same single collect as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UeniBAvrcuvbZMgsM2XrTM
Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
cargo-mutants does not mutate code inside macro_rules! bodies, so the
sign-bit flip and the descending byte inversion written inside
`impl_row_encode_unsigned!` and `impl_row_encode_signed!` were never
mutation tested. Move that logic into the private `#[inline]` const
generic helpers `write_row_bytes` and `write_signed_row_bytes`, leaving
the macros to generate only the `impl RowEncode` boilerplate. The bytes
written, and the panics on a short `out`, are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UeniBAvrcuvbZMgsM2XrTM
Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
cargo-mutants does not mutate code inside macro invocations, so logic
written in a `match_each_pvalue!` arm is never mutation tested. Keep
those arms as thin dispatch and move the logic into private functions:

- `Sequence::is_sorted`: the step sign comparisons move into
  `step_is_sorted`, shared by the unsigned and signed arms (for an
  unsigned step, `step >= 0` is always true, matching the old
  `!strict || v > 0`).
- `SequenceData::normalize`: the unsigned-step canonicalization (`i64`
  when it fits, else `u64`) moves into `canonical_unsigned_step`.
- `eval::step_parts`: the signed direction and magnitude move into
  `signed_step_parts`.

Behavior is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UeniBAvrcuvbZMgsM2XrTM
Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
cargo-mutants does not mutate code inside macro invocations, so the
run-end slicing logic written inside the match_each_unsigned_integer_ptype!
body in run_end_to_arrow was never mutation tested.

Move it into the generic relative_run_ends<E> helper, which picks the runs
covering the slice and rebases their ends onto the slice offset. The macro
now only resolves E and calls the helper; the code monomorphizes as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UeniBAvrcuvbZMgsM2XrTM
Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
cargo-mutants does not mutate code inside macro invocations, so the
bloom filter's float accumulation loop, written inline in a
match_each_float_ptype! body, was never mutation tested.

The loop was identical to the existing generic insert_integer_slice
helper used by the integer path. Rename that helper to
insert_primitive_slice and dispatch both the float and integer paths
to it, so the macro bodies only resolve the type and call the helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UeniBAvrcuvbZMgsM2XrTM
Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
Put the AGENTS.md beside `ptype.rs`, which declares the
`match_each_*_ptype!` macros, instead of at the vortex-array root, so it
is the nearest guidance for that code and moves with it when
vortex-array is split. Point the top-level rule at the new path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UeniBAvrcuvbZMgsM2XrTM
Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
@joseph-isaacs
joseph-isaacs marked this pull request as ready for review November 17, 2026 11:36
@codspeed

codspeed Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Merging this PR will improve performance by 10.52%

2 warnings

⚠️ 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 benchmark is dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚡ 1 improved benchmark
✅ 1961 untouched benchmarks
⏩ 53 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚡ CPU Simulation primitive_i64_vortex 74.7 µs 67.5 µs +10.52%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing ji/mutants-macros-small-crates (6fad610) with develop (7737dbb)

Open in CodSpeed

Footnotes

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

cargo-mutants does not mutate code inside macro invocations, so logic
written in a `match_each_integer_ptype!` body is never mutation tested.
`OnPairDecodePlan::new` summed the uncompressed lengths with a checked
fold inside the macro body. Move that fold into a generic `sum_lengths`
function and keep the macro call as a thin dispatch. The function is
monomorphized per length type exactly as the inline body was.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UeniBAvrcuvbZMgsM2XrTM
Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>

Copy link
Copy Markdown
Contributor Author

CI status: these failures don't come from this PR.

  • Integration smoke tests: fail on develop too. wasm-test/ has no lockfile and picked up fastlanes 0.8.1, which now requires a 'static bound in rle_decompress.rs (E0310). Fixed in Accept fastlanes 0.8.1's 'static bound on RLE decode #11543. I'll merge develop into this branch once that lands.
  • Generated sources, C/C++ API and CMake integration: in this workflow, generate-proto deletes and rewrites vortex-array/src/proto/generated/ in parallel with the FFI build, which then failed to find vortex.dtype.rs. The job passes on the other PRs and on develop. This PR changes no schemas or FFI inputs, and the next run (after the develop merge) should pass.

Generated by Claude Code

Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
@joseph-isaacs
joseph-isaacs merged commit cfb49e2 into develop Nov 17, 2026
80 checks passed
@joseph-isaacs
joseph-isaacs deleted the ji/mutants-macros-small-crates branch November 17, 2026 14:14
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