Repository navigation
perf(analysis): IDW from every point takes the points in blocks, 16 cells at a time - #3009
Conversation
…ells at a time Each cell's pass streamed every point's columns from the shared cache or memory, and held eight lanes of nearest distances beside its two sums, which spilled to the stack. At a power of 2, a run of 16 cells of a row now goes over one block of 512 points before the next, with each point's dy² made once per block and run. The nearest distance is only looked for when the sum of the weights says a point could be within 1e-24. The sums are added in the same order as before. Part of opengeos#1227.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
@coderabbitai full review |
Action performed
|
| /// [`Self::sums`] with w = 1/d² for each of up to [`IDW_CELLS`] cells at `y`, one at each of | ||
| /// `xs`, bit for bit. The points go a block at a time through all the cells, each point's dy² | ||
| /// (the same along the row) made once into `dy2`. | ||
| fn run_sums(&self, xs: &[f64], y: f64, kx: f64, dy2: &mut [f64; IDW_BLOCK]) -> [(f64, f64); IDW_CELLS] { |
There was a problem hiding this comment.
The PR's central claim is that run_sums gives the same bits as sums for every cell, but no test pins that. idw_on_several_threads_is_idw_on_one only compares thread counts, and idw_at_power_two_is_the_general_paths_surface compares against a reference with a tolerance. A later change to the block or lane order could break the bit-for-bit promise without any test failing.
A small test next to this function would close the gap. For a set of points that spans more than two blocks and ends in a partial lane set (the 1,101-point fixture is already right), with a row of 16 cells plus a partial run, assert that run_sums(xs, y, kx, &mut dy2) matches sums(c, kx, |d2| 1.0 / d2) per cell with to_bits() equality on both the numerator and denominator.
This is a test for code that already works, so it is a quality point. The PR's own timing and output comparisons are not in the repository.
Category: quality
There was a problem hiding this comment.
Leaving this for the release quality pass: it's an extra test for code that works, and the bit-for-bit output was checked on nine cases for this PR.
Code reviewI found no bugs, crash paths, or security issues in this change. I checked the arithmetic and the edge cases closely, so I'm fairly confident in the "no bugs" result. The main open item is a missing test for the bit-for-bit claim. I left nothing to re-raise: there are no prior review threads on this PR, so no earlier concerns were skipped. Bugs
Security
Performance
Quality
AGENTS.md
Change sizeCompared: the whole PR against main (merge base 6810fba to PR head 1f5ff00).
|
📖 Docs preview
GitHub Pages takes a minute or two to publish a new commit. Newer commits from the fork aren't published until a maintainer adds the |
Summary
After #2942, IDW from every point at a power of 2 spends about 93% of the benchmark run in the per-cell pass. Two things held that pass back: it streamed all the points' columns from the shared cache or memory again for every cell, and it kept eight lanes of nearest distances beside its two sums, which spilled to the stack.
Output
The same bit for bit: each cell's sums are added in the same eight lanes in the same order. The nine cases below wrote byte-identical GeoTIFFs with
mainand this PR (powers 2, 3 and 0.5, lon/lat and projected points, row widths that aren't multiples of 16, and a point on a cell centre).Timing
Whole
rustgis-cli run(load, IDW, write), release builds ofmainat 6810fba and of this change on it, through the host queue on a shared 4-core, 8-thread box (load average about 7 to 14), runs alternating between the two. Medians; CPU is user plus system. "Benchmark" is the case from #1227: 100,000 points, fieldvalue, onto 100 × 100 cells.main→ PRmain→ PROther powers take the same per-cell pass as before and now measure about 5% more CPU. The instruction count is within 1%, and a standalone build of both versions of that code showed no slowdown, so this looks like how the loop landed in this build.
What remains is the pass itself: one f64 division for each point and cell, two at a time in the baseline x86-64 build.
Memory
Each thread keeps 4 KB of dy² for the block. The point columns are as before, and peak memory in the runs above moved by 1.5 MB or less.
Surfaces
The change is in
rustgis_analysis::rasterops::idw, so it reaches the IDW Interpolation tool everywhere: desktop, browser, command line, Python, and the Assistant and MCP throughgp.run. Nothing saved changes, and there are no new commands or parameters. The browser runs the same blocked pass on one thread. #2927 changes a line of the nearest-few path next to one edited here; whichever lands second has a one-line conflict.Testing
idw_at_power_two_is_the_general_paths_surfacenow uses 1,101 points, so the surface is checked across more than two blocks with points past the last whole set of lanes.idw_on_several_threads_is_idw_on_oneand the underflow tests cover thread counts and the fallback path.cargo fmt --all --check, and the full gate on the fork's CI on this commit.UI evidence
No visible UI change.
Related issue
Part of #1227.
Summary by CodeRabbit