Skip to content

Constant canonicalisation uses similar techniques to SparseArray - #9889

Open
robert3005 wants to merge 2 commits into
developfrom
claude/inspiring-maxwell-he0qon
Open

robert3005 wants to merge 2 commits into
developfrom
claude/inspiring-maxwell-he0qon

Conversation

@robert3005

Copy link
Copy Markdown
Contributor

I have spent quite a bit of time looking at SparseArray canonicalisation and noticed that ConstantArray would benefit from similar improvements

robert3005 and others added 2 commits September 15, 2026 12:29
…ization

`ConstantArray::append_to_builder` already shares one copy of a constant
run's values the way `SparseArray` shares its fill value, but
`constant_canonicalize` still materialized per row. Bring it in line:

- A constant fixed-size list now builds one row's elements and tiles that
  single copy over the run, as `fixed_size_list_fill_tile` does for a
  sparse fill. Elements that are all the same scalar - which a null list's
  placeholders always are - stay one `ConstantArray` covering the whole
  run, so the common cases stop being `list_size * len` scalar appends.
- A constant string or binary run adopts the scalar's own buffer instead
  of copying its bytes, and only when the value is too long to inline. A
  value of exactly `MAX_INLINED_SIZE` bytes lives in its view, so the
  buffer pushed for it was never referenced; `uncompressed_size_in_bytes`
  carried the same off-by-one and is corrected to match.
- A constant list's offsets and sizes take the narrowest width that can
  describe the list, via `match_smallest_list_offset_type!`, rather than
  always costing eight bytes a row once decoded.

Signed-off-by: Robert <robert@spiraldb.com>

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KwhzKebXYiuUjPxBmDdTF9
`execute_sparse_decimal` pushed the fill value through `DecimalBuilder` a
value at a time. Build the buffer directly instead, the way
`constant_canonicalize` already does for a constant decimal run.

Also tightens the comments added in the previous commit.

Signed-off-by: Robert <robert@spiraldb.com>

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KwhzKebXYiuUjPxBmDdTF9
@robert3005 robert3005 added the changelog/performance A performance improvement label Sep 15, 2026
@codspeed

codspeed Bot commented Sep 15, 2026

Copy link
Copy Markdown

Merging this PR will regress 2 benchmarks

⚠️ 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.

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 4 improved benchmarks
❌ 2 regressed benchmarks
✅ 2196 untouched benchmarks
⏩ 218 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation random_i8[0.5] 70.4 µs 94.3 µs -25.33%
WallTime filtered_owned_i64_avx512[OneNullInEight] 22.8 µs 26.7 µs -14.63%
Simulation random_i16[0.95] 97.7 µs 80.1 µs +21.98%
WallTime dict_canonicalize_gt_u8_avx2[16000000] 7.9 ms 6.8 ms +17.06%
Simulation compact_sliced[(1024, 90)] 1.5 µs 1.4 µs +11.92%
Simulation compact_sliced[(2048, 90)] 1.6 µs 1.4 µs +11.42%

Tip

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


Comparing claude/inspiring-maxwell-he0qon (99c8ec3) with develop (c4561ac)

Open in CodSpeed

Footnotes

  1. 218 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.

@robert3005
robert3005 force-pushed the claude/inspiring-maxwell-he0qon branch from cc4d6f2 to 99c8ec3 Compare September 16, 2026 02:00
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.

1 participant