Skip to content

perf(cube): filter the line-envelope x and free domains before the collect - #153

Merged
jvdd merged 2 commits into
mainfrom
perf/cube-envelope-zoomed-prefilter
Oct 6, 2026
Merged

jvdd merged 2 commits into
mainfrom
perf/cube-envelope-zoomed-prefilter

Conversation

@jvdd

@jvdd jvdd commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

The line-envelope cube build collected x, y and the free value of every row, and then the kernel dropped the rows outside the x domain and the free domain. It now filters x, and a range free value, to their domains before the collect, like the other cube builders. The filters use the kernel's closed bounds, so the cube is identical.

The filters run on the cast values after the select. Pushed into a Parquet scan as a typed predicate, the free filter made a 25 % temporal domain 1.65x faster, but an unzoomed one 1.48x slower.

Free domain, release plugin, 8M rows, POLARS_MAX_THREADS=4, 2048 free bins, 500 x buckets, medians of 41 alternating runs:

Data Free domain Before After
Correlated all data 51.9 ms 54.1 ms
Correlated 25 % 33.2 ms 23.3 ms
Uniform all data 199.9 ms 199.3 ms
Uniform 25 % 165.8 ms 76.4 ms

x domain, release plugin, 20M rows, 4 threads, a line target zoomed to 25 % of x. Times are medians of 3 alternating processes of 9 builds. The peak is the phys_footprint above the baseline, lowest of 3 processes:

Source Before After Peak before Peak after
Resident frame 74.3 ms 61.9 ms 229 MB 98 MB
Parquet scan 189 ms 178 ms 548 MB 186 MB

A free domain over 25 % of 20M rows also lowers the peak: from 198 to 75 MB (temporal) and from 356 to 159 MB (Int64) on a resident frame, and from 556 to 196 MB (Float64) on a scan. Domains over all the data use no extra memory. The free filter then costs 0 to 3 %, and the x filter 4 to 5 % on a resident frame and 0 to 5 % on a scan.

  • test_perf_choices.py checks that a build with a zoomed free domain or a zoomed x domain collects only the rows inside it.
  • test_cube.py compares a zoomed x domain with hand-filtered rows (domain edges, NaN, inf, null) for a range and a categorical free axis.
  • The CodSpeed benchmark test_build_line_cubes has an unzoomed, a zoomed-source and a zoomed-target case.

Closes #140

@codspeed

codspeed Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 31 untouched benchmarks
🆕 3 new benchmarks
⏩ 1 skipped benchmark1

Performance Changes

Benchmark BASE HEAD Efficiency
🆕 test_build_line_cubes[unzoomed] N/A 35.1 ms N/A
🆕 test_build_line_cubes[zoomed] N/A 24.2 ms N/A
🆕 test_build_line_cubes[target-zoomed] N/A 16.1 ms N/A

Comparing perf/cube-envelope-zoomed-prefilter (0515aac) with main (c449485)

Open in CodSpeed

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports. ↩

@jvdd jvdd changed the title perf(cube): filter the line-envelope free domain before the collect perf(cube): filter the line-envelope x and free domains before the collect Oct 6, 2026
@jvdd
jvdd merged commit 77861e4 into main Oct 6, 2026
20 checks passed
@jvdd
jvdd deleted the perf/cube-envelope-zoomed-prefilter branch October 6, 2026 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Line-envelope cube: filter a zoomed free domain before the collect

1 participant