From bb98a8ece4918d90d2a195f3afa038371cd5ab3b Mon Sep 17 00:00:00 2001 From: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Date: Mon, 2 Jan 2023 14:22:52 -0800 Subject: [PATCH] Mention use of `--enable-optimizations` and some other useful build options --- Home.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Home.md b/Home.md index 7be8aba..e6580f3 100644 --- a/Home.md +++ b/Home.md @@ -201,4 +201,14 @@ Some of 3rd party tool like [PyInstaller](https://github.com/pyinstaller/pyinsta $ env PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install 3.5.0 ``` -Since pyenv (precisely, python-build) will build CPython with configuring RPATH, you don't have to set `LD_LIBRARY_PATH` to specify library path on GNU/Linux. \ No newline at end of file +Since pyenv (precisely, python-build) will build CPython with configuring RPATH, you don't have to set `LD_LIBRARY_PATH` to specify library path on GNU/Linux. + +### How to build CPython for maximum performance + +Building CPython with `--enable-optimizations` will result in a faster interpreter at the cost of significantly longer build times. +Most notably, this enables PGO (profile guided optimization). While your mileage may vary, it is common for performance improvement from this to be in the ballpark of 30%. +```sh +env PYTHON_CONFIGURE_OPTS='--enable-optimizations --with-lto' PYTHON_CFLAGS='-march=native -mtune=native' pyenv install 3.6.0 +``` + +You can also customize the task used for profile guided optimization by setting the `PROFILE_TASK` environment variable, for instance, `PROFILE_TASK='-m test.regrtest --pgo -j0'` \ No newline at end of file