Add per-codec tile cache benchmark for cuslide2, fix raw TIFF recipe #1143
All Vouch review confidence checks passed
Residual risk 0.23 = Change Risk (0.53) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.53 · 519 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.374
Shallow Review Depth
shallow_review_depth
0.289
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #1143"
general
weight: 0.35
gigony
Addresses the review feedback on #1034 / #1069 from @mkepa-nv, which asked for two things: numbers on whether a warm cache read actually beats decoding again when the codec is light, and whether the tiles would be better cached in GPU memory.
This PR delivers the benchmark. It does not implement a GPU-resident cache — that is an architecture decision (make the global cache device-aware, vs. keep separate CPU and GPU caches as suggested in the thread), and the point of the benchmark is to make that call with evidence rather than intuition.
What the benchmark measures
scripts/benchmark_tile_cache.pysweeps compression × cache setting × output device, timing two access patterns per cell:Cache hit/miss counters are reported for every cell. This is load-bearing rather than decorative: the cache path requires
tile_width_ > 0 && tile_height_ > 0, so whenever nvImageCodec does not reportTileWidth/TileLengththe tile dims stay(0,0)and the cache is bypassed entirely. Without the counters, a run where the cache silently never engaged looks exactly like a run where caching genuinely did not help. The script labels that case instead of printing a meaningless ratio.The CUDA rows need reading carefully
For
device="cuda"this is not a plain cache-vs-no-cache comparison, and the script says so in its output. With the cache off, nvImageCodec decodes straight into device memory:https://github.com/rapidsai/cucim/blob/main/cpp/plugins/cucim.kit.cuslide2/src/cuslide/nvimgcodec/nvimgcodec_decoder.cpp#L317-L374
With the cache on, tiles are decoded to host regardless of the requested output device, assembled there with a single-threaded per-row
memcpy, and the finished region is copied up with onecudaMemcpyHostToDevice.So enabling the cache gives up direct-to-device decode for GPU output. A warm ratio below
1.0xon the CUDA rows is the cost of that host round-trip, and is an argument for the GPU-resident cache in #1069 rather than against caching in general. Worth noting the infrastructure is already most of the way there:PerProcessImageCache::allocate()callscudaMallocwhen constructed withDeviceType::kCUDA, the global cache simply never is, and legacy cuslide'sNvJpegProcessoralready keeps a private device-resident tile cache as a working in-tree reference.Generator fix (prerequisite)
The uncompressed case central to the review feedback could not be generated at all. In
gen_tiff.py,rawmapped toNoneand was then overwritten:So every
testimg_tiff_stripe_*_rawfixture has in fact been producing JPEG images, and unknown compression names took the same silent fallback. Both are fixed; unknown names now raise.Verified directly:
Reviewer notes
gen_tiff.pyfeeds the compression-parametrized fixtures used acrosstest_tiff_read_region.py,test_batch_decoding.pyandtest_load_image_metadata.py. I checked their assertions are structural (e.g.assert np.all(channel_value_count > 0)) rather than exact-pixel comparisons, so lossy→lossless should be safe, but I had no cuCIM install or GPU available to run the suite locally.4096x4096rawfixture gets materially larger now that it is genuinely uncompressed instead of silently JPEG.--discard_cachein the C++ benchmarks only drops the OS page cache viaposix_fadvise, not cuCIM'sImageCache, so no existing C++ benchmark exercises the tile cache.