Build the wheel with a single copy of libcucim #1220
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 395 lines diff across 4 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.358
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1220"
general
weight: 0.35
gigony
Summary
closes #1213
The pip wheels load two copies of libcucim. After opening a file,
/proc/self/mapslists both:cucim/clara/_cucim.soneedslibcucim.so.26, found next to it incucim/clara/.cucim.kit.cuslide@.so,cucim.kit.cuslide2@.so,cucim.kit.cumed@.so) needlibcucim-<hash>.so.<version>incucim_cu13.libs/, a renamed copy thatauditwheel repairvendored.
Each copy has its own global state, so the cache configured from Python is not the one the plugins
use. With a per-process cache and statistics recording on, a cold
read_regionrecords neither hitsnor misses, for both cuslide and cuslide2:
I saw this with
cucim-cu13==26.10.0and the26.12.0a34nightly. The conda packages and a sourcebuild load one copy and record misses. It also makes the caching step of
scripts/test_aperio_svs.pyandscripts/test_philips_tiff.pyfail with wheels.Cause
The wheel is assembled from the CMake build tree (
run build_localcopiesbuild-release/lib/cucimintopython/cucim/src/cucim/clara/). In the build tree, the plugins'RUNPATH is the absolute path of the libcucim build directory and has no
$ORIGIN, becauseCMAKE_INSTALL_RPATH($ORIGIN) only applies to the installed copy. The Python extension findslibcucim.so.26through$ORIGIN, soauditwheelsees it as part of the wheel. For the plugins itresolves
libcucim.so.26to the build directory, copies that file intocucim_cu13.libs/with ahashed name, and rewrites the plugins'
NEEDEDentry to the new name.Changes
BUILD_WITH_INSTALL_RPATHon the three plugin targets, so the plugins in the build tree haveRPATH
$ORIGIN, like the installed ones.auditwheelthen finds thelibcucim.so.26that isalready in the wheel.
ci/validate_wheel.shfails if a wheel contains a vendored.libs/libcucim-.test_libcucim_loaded_once.py: after a read by a plugin, exactly one libcucim ismapped into the process, and the cache configured from Python has recorded the read. It uses a
generated TIFF, so no download is needed.
Testing
I reproduced the problem with
auditwheel6.8.2 on a wheel assembled from a local source build ofmain:| Plugins' RUNPATH in the wheel |
auditwheel repairresult ||---|---|
| absolute build path (current) | adds
cucim.libs/libcucim-f2d0d9dd.so.26.12.00||
$ORIGIN(the new RPATH) | adds nothing; onelibcucim.so.26in the wheel |The second row was made with
patchelf --set-rpath '$ORIGIN'on the plugins, which is what theCMake property does to the files in the build tree. I did not rebuild the plugins with the changed
CMake files and then make a wheel. The new check in
validate_wheel.shflags the first wheel andaccepts the second. The new unit test passes with a source build.
CI builds the wheels, so the wheel build,
validate_wheel.shand the wheel tests are the finalcheck.