Skip to content

[Perf] Release the GIL in compute-intensive function#60

Merged
haochengxia merged 2 commits into
mainfrom
hxia/fix-gil
May 17, 2026
Merged

[Perf] Release the GIL in compute-intensive function#60
haochengxia merged 2 commits into
mainfrom
hxia/fix-gil

Conversation

@haochengxia
Copy link
Copy Markdown
Collaborator

#59

Fixed by release GIL.

[INFO]  05-17-2026 00:42:47 cli_reader_utils.c:213  (tid=129999368357568): detecting trace type: ORACLE_GENERAL_TRACE
Thread A starting simulation...
[INFO]  05-17-2026 00:42:47 cli_reader_utils.c:213  (tid=129999034611392): detecting trace type: ORACLE_GENERAL_TRACE
Thread B starting simulation...
Thread B completed in 0.52s
Thread A completed in 0.54s

Total elapsed time: 0.57s

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request implements Global Interpreter Lock (GIL) management in the C++ cache export layer to enable multi-threaded trace processing from Python. Key changes include adding py::gil_scoped_acquire to cache operations that interact with Python objects and utilizing py::call_guard<py::gil_scoped_release> in the Python bindings for long-running simulation tasks. A new test suite, tests/test_gil.py, was added to verify concurrent execution. Review feedback highlights the need to acquire the GIL during cache destruction in pypluginCache_free to avoid crashes when cleaning up Python-owned parameters and suggests optimizing pypluginCache_get by delaying GIL acquisition until after the core C++ lookup is complete to reduce thread contention.

Comment thread src/export_cache.cpp
Comment thread src/export_cache.cpp Outdated
@haochengxia haochengxia merged commit 7079d27 into main May 17, 2026
26 checks passed
@haochengxia haochengxia deleted the hxia/fix-gil branch May 17, 2026 05:26
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