[FEATURE]: create python binding#128
Conversation
ebbd4a6 to
fea7e86
Compare
|
Our project now includes initial Python bindings. Regarding Therefore, I am considering different methods to support the full check,
|
Since we have disabled clang-tidy, do we still need this? |
Removing it |
|
Awesome work! One concern that I have: If we only support running one request each time, it would be very slow, shall we support finding the trace length. i.e., #requests, #seconds, and replay the full trace, a fraction of the trace, N requests, N seconds of requests? |
Good question! I think we can support it. The abstraction for this is that we do not move the data to the Python side but directly consume it in the C side. graph LR
C --Req--> Python --Req--> C;
graph LR
C --Req--> C;
Therefore we should have a structure at C/Python sides to represent a range of requests. Currently, only working set size is exposed at the Python side. We can add other methods to The interface looks like In the future, we can add seamless data communication by zero-copy data movement. Directly interpreting data in each side. graph LR
C --Reqs--> Python;
Python --Reqs--> C;
|
0ab5446 to
fffa5db
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR adds Python bindings for libCacheSim, including C++ wrapper code, Python package modules, build scripts, and comprehensive tests and examples.
- Introduce
pylibcachesim.cppto expose core simulator APIs via Pybind11 - Add Python package structure under
libCacheSim-pythonwitheviction,const, and__init__modules - Provide build helper scripts (
sync_python_version.py,install_python.sh), CMake integration, and CI workflow - Include extensive tests in
libCacheSim-python/testsand usage examples
Reviewed Changes
Copilot reviewed 25 out of 27 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/sync_python_version.py | Script to sync Python package version |
| scripts/install_python.sh | Automated Python binding build/install script |
| libCacheSim-python/src/pylibcachesim.cpp | Pybind11 C++ wrapper for libCacheSim API |
| libCacheSim-python/pyproject.toml | Python package metadata and build config |
| libCacheSim-python/CMakeLists.txt | CMake setup for building Python extension |
| CMakeLists.txt (root) | Export CMake vars for Python binding |
| .github/workflows/python.yml | GitHub Actions for Python build and tests |
| libCacheSim-python/libcachesim/const.py | Define Python-side TraceType enum |
| libCacheSim-python/libcachesim/eviction.py | High-level Python eviction policy registry |
| libCacheSim-python/libcachesim/init.py | Package initialization exports |
| libCacheSim-python/libcachesim/init.pyi | Stub declarations for typing |
| libCacheSim-python/tests/utils.py | Test utility for reference data lookup |
| libCacheSim-python/tests/test_unified_interface.py | Tests unified interface across policies |
| libCacheSim-python/tests/test_python_hook_cache.py | Tests PythonHookCachePolicy implementation |
| libCacheSim-python/tests/test_process_trace.py | Tests process_trace for native and hook caches |
| libCacheSim-python/tests/test_eviction.py | Parametrized eviction policy correctness tests |
| libCacheSim-python/tests/reference.csv | Reference miss-ratio data |
| libCacheSim-python/tests/pytest.ini | Pytest configuration |
| libCacheSim-python/tests/conftest.py | Pytest fixtures |
| libCacheSim-python/examples/python_hook_cache_example.py | Example of custom hook caches |
| libCacheSim-python/examples/demo_unified_interface.py | Unified interface demo script |
| libCacheSim-python/export/README.md | Documentation for CMake export mechanism |
| libCacheSim-python/export/CMakeLists.txt | Export selected project variables to Python |
| libCacheSim-python/.gitignore | Ignore rules for Python build artifacts |
|
Uploaded to PyPI |
|
We may also want to promote the Python package on the frontpage README, but this can be added in a separate PR. |
|
Shall I merge it? |
|
Yes, it can merged now. |
|
Congratulations on the exciting feature! |
Roadmap in #123
Example