Repository navigation
fix: numba cache data files named by key, so concurrent compiles can't mix up signatures - #216
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #216 +/- ##
==========================================
+ Coverage 92.89% 92.96% +0.07%
==========================================
Files 21 21
Lines 1576 1593 +17
==========================================
+ Hits 1464 1481 +17
Misses 112 112
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary: When several processes compile different signatures of the same numba kernel at the same time against one on-disk cache, the cache can end up mapping one signature to another signature's machine code. Every later call with that signature then fails with "can't unbox array from PyObject", until the cache is deleted. This PR names each cached data file after its cache key, so a data file can only ever hold the code for its own key.
Background:
Changes:
infercnvpy._numbahas a smallnjithelper:numba.njit(nogil=True)with a cache whose data files are named after a hash of the cache key. Each data file is written before the index.njit_parallelbuilds both twins with it, so it is still a parallel kernel on the main thread and a serial nogil twin elsewhere. The other cached kernels use it too.IndexDataCacheFile,FunctionCache), which are not public API.Testing:
tests/test_numba_cache.pyforces the bad write order between two loads of a kernel module in one subprocess, then calls the kernel with float32 and float64 in a fresh subprocess. It fails on main with the "can't unbox array" error and passes with this change.