Skip to content

ci: every concurrent process writes its own numba cache - #47

Merged
SMI-Lab-Inha merged 1 commit into
devfrom
ci/numba-cache-isolation
Nov 19, 2026
Merged

SMI-Lab-Inha merged 1 commit into
devfrom
ci/numba-cache-isolation

Conversation

@SMI-Lab-Inha

@SMI-Lab-Inha SMI-Lab-Inha commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

Summary

numba's on-disk cache is not safe for two processes that compile the same kernel for different signatures at the same time. IndexDataCacheFile.save (numba/core/caching.py) chooses a new entry's data-file number from the index it last read, and saves the index before the data. Two such processes can both take <kernel>.1.nbc, and the index can be left pointing at the other process's overload. A later process that loads that entry gets machine code compiled for another signature.

#45 already gives each pytest-xdist worker its own cache. Two gaps remain, and this PR closes them:

Process Before After
run_validation.py --jobs=N row-group workers one pool; all workers share numba's default cache N one-process spawn pools, each started while NUMBA_CACHE_DIR names its own directory; groups go to the workers in turn, slowest first
concurrent taxonomy runs without xdist they would share the default cache each run gets its own directory (under xdist, each worker a subdirectory of it)
xdist worker with an explicit NUMBA_CACHE_DIR all workers shared it each worker uses its own subdirectory of it
required aggregate job "Coverage and validation report" no limit (360 min default) timeout-minutes: 10

The temporary cache directories are removed at the end of the run. Nothing else changes: same tests, same rows, same report, same --check condition.

Evidence

  • _isolated_pool: the worker sees its own NUMBA_CACHE_DIR, the parent's environment is restored, the worker writes its cache files there, and the _dai2018_rows group computed in the worker equals the serial result exactly.
  • The rows of _evaluate_rows with the isolated pools against serial _rows(): all 67 rows identical as exact (tier, ident, quantity, target, value, status) tuples.
  • The CI run of this PR: --check --jobs=auto must reproduce the committed report and its taxonomy lines exactly.

Not in this PR

  • The same race in the library: sea_state_batch spawn workers with workers > 1 share one cache. It gets its own PR with a cold-cache test.
  • Sharing one compiled cache safely between the workers (a lock around compile and save). Measured locally, compiling costs about a minute per worker (a cold cache 895 s against 836 s warm for one _rows() test), so this isolation costs little.

numba numbers a new on-disk cache entry from the index it last read and saves
the index before the data, so two processes that compile one kernel for
different signatures at the same time can both take the same data file and
leave the index pointing at the other's overload. The pool workers of
run_validation.py --jobs shared numba's default cache directory.

Each row-group worker is now a one-process spawn pool started while
NUMBA_CACHE_DIR names its own directory; the groups go to the workers in
turn, slowest first. Each concurrent taxonomy run takes its own directory
too, and under xdist tests/conftest.py makes each worker's directory a
subdirectory of an explicit NUMBA_CACHE_DIR instead of sharing it. The
required aggregate job gets a 10-minute limit.

Signed-off-by: Jae Hoon Seo <jaehoon.seo@inha.ac.kr>
@SMI-Lab-Inha

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-19T09:12:57.427156Z 2c4e00b Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 CableXSec | 🛠️ Build #36007979 | 📁 Comparing 2c4e00b against latest (240bf9c)

  🔍 Preview build  

23 files changed · ± 23 modified

± Modified

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 2c4e00bf3d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@SMI-Lab-Inha
SMI-Lab-Inha merged commit 02bc61f into dev Nov 19, 2026
14 checks passed
@SMI-Lab-Inha
SMI-Lab-Inha deleted the ci/numba-cache-isolation branch November 19, 2026 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant