From bbc9e3f009b1fc26e5b479d15ed1892a98da6f6a Mon Sep 17 00:00:00 2001 From: vladkvit Date: Thu, 9 Jul 2026 10:32:50 -0400 Subject: [PATCH 1/2] Add commands to run PGO optimization --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index cd3c91c..1e3bbb9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["maturin>=1.7,<2.0"] +requires = ["maturin>=1.13,<2.0"] build-backend = "maturin" [project] @@ -17,3 +17,4 @@ dependencies = [ ] [tool.maturin] features = ["pyo3/extension-module"] +pgo-command = "python src/bench_parse_games.py" From 84b95e67eab642092c2747738d2e50852cc662cf Mon Sep 17 00:00:00 2001 From: Vlad K <2459295+vladkvit@users.noreply.github.com> Date: Mon, 21 Sep 2026 10:17:27 -0400 Subject: [PATCH 2/2] Add a PGO note --- PGO.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 PGO.md diff --git a/PGO.md b/PGO.md new file mode 100644 index 0000000..59419ef --- /dev/null +++ b/PGO.md @@ -0,0 +1,11 @@ +# PGO + +- Requires maturin >= 1.13 and `rustup component add llvm-tools` (for llvm-profdata). +- `maturin develop` ignores PGO — build the wheel explicitly: + + `maturin build --release --pgo` + +- This runs a 3-phase build. 1) instrumented wheel 2) trains by running `pgo-command` from pyproject.toml (`python src/bench_parse_games.py`) in a temp venv 3) optimized rebuild. +- Training needs `2013-07-train-00000-of-00001.parquet` in the working dir. +- Optimized wheel lands in `target/wheels/`; install with `pip install --force-reinstall --no-deps target\wheels\rust_pgn_reader_python_binding-*-win_amd64.whl`. +- Measured vs main (median of 5 interleaved runs): MT parse 0.176s → 0.146s (~17% faster), ST parse 1.34s → 1.23s (~8% faster).