Skip to content

Transformations: Isolated CI JIT test#696

Draft
mlange05 wants to merge 4 commits into
mainfrom
naml-test-jit-isolated
Draft

Transformations: Isolated CI JIT test#696
mlange05 wants to merge 4 commits into
mainfrom
naml-test-jit-isolated

Conversation

@mlange05
Copy link
Copy Markdown
Collaborator

@mlange05 mlange05 commented Jun 3, 2026

Description

This PR aims to address a long-standing issue with racy failure in the transformation test base. In particular, test_parametrise.py creates multiple variations of the same module procedures with varying signatures and no renaming for the various test variations, leading to a racy situation where the assignment of two subsequent variants in the same thread can cause symbol aliasing and thus trigger mem corruption and sigsevs. To prevent this, simple de-aliasing techniques are not sufficient, as the compiled fortran symbols are still loaded dynamically into the Python runtime within the same process.

To fix this, this PR adds a small run_isolated utility that executes a helper method in a short-lived child process, allowing the compile-and-check utility in the problematic test to be forced onto a separate process and thus avoid dynamic symbol aliasing.

Contributor Declaration

By opening this pull request, I affirm the following:

  • All authors agree to the Contributor License Agreement.
  • The code follows the project's coding standards.
  • I have performed self-review and added comments where needed.
  • I have added or updated tests to verify that my changes are effective and functional.
  • I have run all existing tests and confirmed they pass.

mlange05 added 4 commits June 3, 2026 04:27
Provide a reusable run_isolated utility for JIT tests that need native
extension work to happen in a short-lived child process, preventing
loaded f90wrap state from leaking into the pytest worker. Cover result
propagation, Python exceptions, and non-zero child exits.
Run the compile-and-execute phase of the parametrise transformation
tests in a short-lived child process. This prevents f90wrap modules
and native Fortran symbols loaded by one parametrised test case from
leaking into later cases scheduled on the same xdist worker.
Document the expected area-prefixed subject format and wrapped body style so future local commits follow the repository convention consistently.
Allow isolated JIT helpers to use a clean spawn context and to exit immediately after reporting a successful result. This avoids f90wrap or Fortran finalizers crashing during child interpreter shutdown while still surfacing Python exceptions and non-zero exits.

Use the hardened isolation in parametrise transformation tests and keep generated module names unique so wider xdist runs cannot alias native symbols across concurrently compiled cases.
@mlange05 mlange05 requested review from MichaelSt98 and reuterbal June 3, 2026 06:45
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 3, 2026

Documentation for this branch can be viewed at https://sites.ecmwf.int/docs/loki/696/index.html

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 3, 2026

Codecov Report

❌ Patch coverage is 74.64789% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.16%. Comparing base (8315ebd) to head (6a497e8).

Files with missing lines Patch % Lines
loki/jit_build/jit.py 75.00% 8 Missing ⚠️
loki/transformations/tests/test_parametrise.py 53.84% 6 Missing ⚠️
loki/jit_build/tests/test_build.py 84.61% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #696      +/-   ##
==========================================
- Coverage   94.20%   94.16%   -0.05%     
==========================================
  Files         288      288              
  Lines       47625    47686      +61     
==========================================
+ Hits        44867    44903      +36     
- Misses       2758     2783      +25     
Flag Coverage Δ
lint_rules 96.40% <ø> (ø)
loki 94.13% <74.64%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mlange05 mlange05 changed the title Naml test jit isolated Transformations: Isolated CI JIT test Jun 3, 2026
@mlange05 mlange05 marked this pull request as draft June 3, 2026 07:21
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