Skip to content

[NOGIL] Add CI verification jobs for free-threaded Python 3.14t#2304

Merged
Ojasva Jain (ojasvajain) merged 3 commits into
dev_thread_free_supportfrom
add_314t_sem_jobs
Jul 16, 2026
Merged

[NOGIL] Add CI verification jobs for free-threaded Python 3.14t#2304
Ojasva Jain (ojasvajain) merged 3 commits into
dev_thread_free_supportfrom
add_314t_sem_jobs

Conversation

@ojasvajain

@ojasvajain Ojasva Jain (ojasvajain) commented Jul 6, 2026

Copy link
Copy Markdown
Member

First step toward free-threading (no-GIL) support: run source-package verification and integration tests against CPython 3.14t on every commit.

  • New Semaphore block with classic and consumer group-protocol jobs on 3.14t.
  • requirements-tests-install-nogil.txt — test deps without the rules/json-fast extras, whose compiled deps (tink, google-re2, grpcio; orjson) ship no free-threaded wheels; selected by the verification script on free-threaded builds.
  • Collection exclusions for the 11 schema_registry test modules importing those deps.
  • GIL-status fixture warning when the GIL is re-enabled; becomes an assertion once cimpl declares support.

Note: cimpl doesn't yet declare Py_MOD_GIL_NOT_USED, so these jobs run with the GIL re-enabled — they validate the 3.14t toolchain and packaging, not lock-free execution. cp314t wheels and the thread-safety work will be added in a separate PR.

What

Checklist

  • Contains customer facing changes? Including API/behavior changes
  • Did you add sufficient unit test and/or integration test coverage for this PR?
    • If not, please explain why it is not required

References

JIRA:

Test & Review

Open questions / Follow-ups

  - Add a Semaphore block running source package verification and
    integration tests on CPython 3.14t (classic and consumer group
    protocols). cimpl does not declare free-threading support yet, so
    importing it re-enables the GIL: these jobs validate the 3.14t
    toolchain and packaging until that declaration ships.
  - Skip the CI-only orjson install on free-threaded interpreters: no
    free-threaded orjson wheels exist and the source build would fail;
    the stdlib JSON fallback path stays covered.
  - Add a module-scoped autouse fixture (defined on free-threaded builds
    only) that warns when the GIL is re-enabled around a test module.
    Hard asserts are staged behind TODO FTS markers, to be enabled in the
    same PR that declares Py_MOD_GIL_NOT_USED.

  Interpreter detection follows the free-threading HOWTO:
  https://docs.python.org/3/howto/free-threading-python.html
@confluent-cla-assistant

Copy link
Copy Markdown

🎉 All Contributor License Agreements have been signed. Ready to merge.
Please push an empty commit if you would like to re-run the checks to verify CLA status for all contributors.

  On free-threaded (no-GIL) builds, the rules and json-fast extras'
  compiled deps (tink, google-re2, grpcio; orjson) ship no free-threaded
  wheels and fail to build from source, so:

  - Add requirements-tests-install-nogil.txt, a variant of
    requirements-tests-install.txt without those extras, and install it
    from source-package-verification.sh when the interpreter is
    free-threaded (detected via Py_GIL_DISABLED).
  - Exclude the schema_registry test modules that import tink/celpy/orjson
    at the top of the file from collection on free-threaded builds only;
    on regular builds a missing dep stays a loud collection error rather
    than a silent skip. Plain serdes coverage recovery is marked as a
    TODO NOGIL follow-up.
@sonarqube-confluent

Copy link
Copy Markdown

Quality Gate passed Quality Gate passed

Issues
4 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarQube

@rayokota Robert Yokota (rayokota) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@k-raina Kaushik Raina (k-raina) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for raising PR. Provided first pass of comments

Comment thread .semaphore/semaphore.yml
- cp test-report.xml test-output
- test-results publish test-output
- artifact push workflow coverage.xml
- name: "Source package verification and Integration tests with Python 3.14t free-threaded (Linux x64)"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why we are adding new jobs and not changing current ones?
Adding new jobs and running old ones too means additional costs.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The existing job runs on 3.11 which is a GIL based Python. We need this new job because there are some differences in how the GIL free Python behaves:

  1. There are some dependencies that do not provide free threaded wheels. If such deps are imported in the code, the job will fail. The code author should then take steps to exclude it and possibly document the behaviour saying that XYZ functionality is not supported on free threaded Python builds.

  2. There is a good difference in the underlying CPython 3.14t vs any GIL based CPython. It is important we ensure all our existing test cases pass. Also I have added a fixture that will ensure GIL does not get enabled during a test run. That fixture will be applicable only when we run test cases on 3.14t. Currently the fixture is commented out, but I have a TODO to enable it once I make the core changes.

Comment thread .semaphore/semaphore.yml
jobs:
- name: Build and Tests with 'classic' group protocol
commands:
- sem-version python 3.11

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is using 3.11 version intentional?

@ojasvajain Ojasva Jain (ojasvajain) Jul 16, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. sem-version does not provide 3.14t. So I am setting 3.11 as the host Python interpretor and then I am using uv and venv to set the version of the virtual environment to 3.14t
uv venv _venv --python 3.14t && source _venv/bin/activate.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering that this PR merged into feature beanch, why are we not making changes to requirements/requirements-tests-install.txt ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added a branch in source-package-verification.sh to use requirements-tests-install when running on GIL based Python. There are certain deps in requirements-tests-install that are not supported on GIL free python so I had to exclude them and create a new file called requirements-tests-install-nogil.

@k-raina Kaushik Raina (k-raina) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for PR Ojasva Jain (@ojasvajain) . LGTM!

@ojasvajain Ojasva Jain (ojasvajain) merged commit 9412d74 into dev_thread_free_support Jul 16, 2026
4 checks passed
@ojasvajain Ojasva Jain (ojasvajain) deleted the add_314t_sem_jobs branch July 16, 2026 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants