Repository navigation
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
Merging this PR will improve performance by ×4.1
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | test_rank_filter[1237x811-L-Min3] |
242 ms | 10.7 ms | ×23 |
| ⚡ | test_rank_filter[1237x811-F-Min3] |
252 ms | 29.6 ms | ×8.5 |
| ⚡ | test_rank_filter[1237x811-I-Min3] |
264.5 ms | 33.4 ms | ×7.9 |
| ⚡ | test_rank_filter[1237x811-F-Median3] |
275.9 ms | 55 ms | ×5 |
| ⚡ | test_rank_filter[1237x811-L-Median3] |
244.4 ms | 57.1 ms | ×4.3 |
| ⚡ | test_rank_filter[1237x811-I-Median3] |
268.2 ms | 69.6 ms | ×3.9 |
| ⚡ | test_rank_filter[1237x811-F-Median5] |
566.1 ms | 344.8 ms | +64.18% |
| ⚡ | test_rank_filter[1237x811-L-Median5] |
476.3 ms | 366.5 ms | +29.96% |
| ⚡ | test_rank_filter[1237x811-I-Median5] |
527.3 ms | 421 ms | +25.25% |
Tip
Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.
Comparing akx:top-ranking (a84857d) with main (ad277e2)
Footnotes
-
338 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. ↩
|
The min/max speedup isn't as drastic on Codspeed - I presume GCC isn't optimizing that well. |
This removes the `IMAGING_PIXEL_(type)` macros from `Imaging.h` too; they were only used in `RankFilter.c` and in one place in `_imaging.c`.
|
Call me crazy, but the |
|
The CSWAP stuff is in the last commit, it's easy to split out. However, as noted, it's public domain code that's probably been vetted by others and AIUI it's all versioning of this code originally published in 1990 in Graphics Gems: https://github.com/erich666/GraphicsGems/blob/master/gems/Median.c I locally verified it to be exact against the previous implementation with some thousands of random images, too. But if you like, say the word and I'll rebase this without the last commit (later tonight I'm not on mobile on a train between Hiroshima and Iwakuni 😀). |
Tangentially refs #10041 (but doesn't include that GIL release).
This PR:
ImagingExpand(which underpinsRankFilter), and makes it correct for 16-bpc dataRankFilter.c.IMAGING_PIXEL_<dtype>macros from_imaging.h. They were only used inRankFilter(which no longer does image row pointer acquisition for every pixel) and in 2 places in_imaging.c.On my machine, this shows a rather shocking speedup for the common benchmarked cases:
Adding support for
I;16images inRankFilteris a small patch on top of it if it's desired, but it felt out of scope for this PR.