| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
- Declare free-threading compatibility on pybind11 modules (`mod_gil_not_used`) and BUILD targets (`freethreading_compatible`). - Introduce `FreeThreadingMutex`, a zero-cost abstraction that compiles away in GIL-enabled builds and uses `absl::Mutex` in free-threaded mode (`Py_GIL_DISABLED`). - Protect lazy `cel_program_` compilation in `PyCelExpression` with `FreeThreadingMutex`. - Protect Python object caching and lazy element resolution in `PyCelValue` and list/map accessors with `FreeThreadingMutex`. - Protect `PyMessageFactory::message_classes_` with `FreeThreadingMutex`. - Extract `BuildCompiler` and `BuildRuntime` to construct compiler/runtime objects without holding mutex locks, using double-checked locking in `GetCompiler` and `GetRuntime`. - Eagerly resolve `variable_types_` during `PyCelEnvInternal` initialization, making `GetVariableType` lock-free and thread-safe. - Release GIL during CPU-bound policy compilation and YAML parsing. - Avoid unconditional `gil_scoped_acquire` across destructors and error conversions when GIL state is already held (`PyGILState_Check`). - Initialize pybind11 internals at module import time to prevent DSO internals races in multi-threaded environments. - Prevent reference leaks in custom function invocation by releasing arguments and temporary results. - Add `test_freethreaded.sh` script and concurrency tests in `cel_parallel_test.py` and `cel_test.py`. ### Performance Benchmarks (`cel_parallel_test`, `-c opt`) | Benchmark Stage / Test Case | Standard Mode (GIL) | Free-Threaded Mode (No GIL) | Speedup / Impact | | :--- | :---: | :---: | :---: | | **Multi-Threaded Compilation** (1,000 items, 8 threads) | 75.74 ms | 23.14 ms | **3.27x faster** (69.5% faster) | | **Sequential Compilation** (1,000 items) | 61.77 ms | 63.28 ms | 0.98x | | **Multi-Threaded Evaluation** (10,000 items, 8 threads) | 234.79 ms | 138.88 ms | **1.69x faster** (40.9% faster) | | **Sequential Evaluation** (10,000 items) | 90.68 ms | 112.74 ms | 0.80x | PiperOrigin-RevId: 970936071
| Back | FazBrowse Home | New Git URL |
Enable free-threaded Python and improve concurrency in CEL Python.
Performance Benchmarks (cel_parallel_test, -c opt)