From 34eda2fc4410763f919ab0e9961c25db60298860 Mon Sep 17 00:00:00 2001 From: ChrisRackauckas-Claude Date: Fri, 10 Apr 2026 07:30:19 -0400 Subject: [PATCH] CI: serialize precompile workers for python-using groups MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `OptimizationSciPy` (and occasionally `OptimizationPyCMA`) jobs have been observed to fail at the precompile stage with InitError: UndefRefError: access to undefined reference [1] _pyjl_new(...) @ PythonCall.JlWrap.Cjl ~/.julia/packages/PythonCall/.../JlWrap/C.jl:24 ... [11] __init__() @ PythonCall.JlWrap ~/.julia/packages/PythonCall/.../JlWrap/JlWrap.jl:70 during initialization of module JlWrap with the *same* PythonCall version (`0.9.31`) on which other CI runs succeed (`OptimizationSciPy lts` passes on master run 24144818227 but the same job fails on PR run 23171032225). The intermittency, identical package versions, and the failure happening inside PythonCall's own wrapper-type registration during JlWrap.__init__ all point at a parallel precompile race: when multiple precompile workers spin up wrapper-type registration concurrently, one of them observes a not-yet-populated Python type slot and throws `UndefRefError`. `Pkg.precompile()` reads `JULIA_NUM_PRECOMPILE_TASKS` (see base/precompilation.jl:437) to size its parallel-task semaphore. Setting it to `1` for the python-using jobs serializes precompile workers and removes the race. The cost on these small subpackages is negligible. Targeted to OptimizationSciPy and OptimizationPyCMA only — other groups keep the default parallel precompile. Co-Authored-By: Chris Rackauckas --- .github/workflows/CI.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 4e6862d83..f51524927 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -64,6 +64,14 @@ jobs: ${{ runner.os }}-test-${{ matrix.version }}-${{ env.cache-name }}- ${{ runner.os }}-test-${{ matrix.version }}- ${{ runner.os }}- + # Serialize precompile workers for the python-using groups. PythonCall's + # `JlWrap.__init__` has been observed to fail intermittently with + # `UndefRefError: access to undefined reference` when multiple precompile + # workers spin up the wrapper-type registration concurrently. Setting + # `JULIA_NUM_PRECOMPILE_TASKS=1` removes that race; the cost on these + # small subpackages is negligible. + - if: ${{ matrix.group == 'OptimizationSciPy' || matrix.group == 'OptimizationPyCMA' }} + run: echo "JULIA_NUM_PRECOMPILE_TASKS=1" >> $GITHUB_ENV - uses: julia-actions/julia-buildpkg@v1 - if: ${{ matrix.group == 'OptimizationQuadDIRECT' }} run: julia --project -e 'using Pkg; Pkg.Registry.add(RegistrySpec(url = "https://github.com/HolyLab/HolyLabRegistry.git")); Pkg.add("QuadDIRECT")'