Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make BOLT as stable feature #101525

Open
3 of 6 tasks
corona10 opened this issue Feb 2, 2023 · 5 comments
Open
3 of 6 tasks

Make BOLT as stable feature #101525

corona10 opened this issue Feb 2, 2023 · 5 comments
Assignees
Labels
build The build process and cross-build performance Performance or resource usage type-feature A feature request or enhancement

Comments

@corona10
Copy link
Member

corona10 commented Feb 2, 2023

Using a BOLT still not guarantee the unexpected behavior changes.
For example, I observed that #53093 is raised if the binary is optimized by BOLT.
We can reduce several too aggressive optimization.

  • Tune the optimization flags
  • Choose the APIs that should not be optimized BOLT (e.g -skip-funcs)
  • Update libregrtest.utils.get_build_info()
  • Update make test to work correctly (Should skip the BOLT phase if the binary is already BOLTed)
  • Define minimum LLVM version
  • Enhance the BOLT build process #101282

cc @aaupov

Linked PRs

@corona10 corona10 added type-feature A feature request or enhancement performance Performance or resource usage labels Feb 2, 2023
@corona10 corona10 self-assigned this Feb 2, 2023
@corona10
Copy link
Member Author

corona10 commented Feb 2, 2023

I am analyzing several effects of BOLT.

@corona10
Copy link
Member Author

corona10 commented Feb 8, 2023

Need to update get_build_info for the BOLT binary.

@corona10
Copy link
Member Author

corona10 commented Feb 24, 2023

Consider a way to detect post-bolted binary: llvm/llvm-project#60253

corona10 added a commit to corona10/cpython that referenced this issue Apr 2, 2023
corona10 added a commit that referenced this issue Apr 5, 2023
gaogaotiantian pushed a commit to gaogaotiantian/cpython that referenced this issue Apr 8, 2023
warsaw pushed a commit to warsaw/cpython that referenced this issue Apr 11, 2023
corona10 added a commit to corona10/cpython that referenced this issue Apr 16, 2023
indygreg added a commit to indygreg/cpython that referenced this issue May 20, 2023
(This change is a quick and dirty way to merge some of the build system
improvements I'm proposing in pythongh-101093 before the 3.12 feature freeze.
I wanted to scope bloat myself to fix some longstanding deficiencies in
the build system around profile-guided builds. But I'm getting soft
resistance to the reviews so close to the freeze deadline and it is
obvious that we need a simpler solution to hit the 3.12 deadline. While
this change is quick and dirty, it attempts to not make things worse.)

Before this change, we only applied bolt to the main python binary.
After this change, we apply bolt to libpython if it is configured. In
shared library builds, most of the C code is in libpython so it is
critical to apply bolt to libpython to realize bolt benefits.

This change also reworks how bolt instrumentation is applied. It
effectively removes the readelf based logic added in pythongh-101525 and
replaces it with a mechanism that saves a copy of the pre-bolt binary
and restores that copy when necessary. This allows us to perform
bolt optimizations without having to manually delete the output binary
to force a new bolt run.

We also add a new make target for purging bolt files and hook it up
to `clean` so bolt state is purged when appropriate.

`.gitignore` rules have been added to ignore files related to bolt.

Before and after this refactor, `make` will no-op after a previous run.
Both versions should also share common make DAG deficiencies where
targets fail to trigger as often as they need to or can trigger
prematurely in certain scenarios. e.g. after this change you may need
to `rm profile-bolt-stamp` to force a bolt run because there aren't
appropriate non-phony targets for bolt's make target to depend on.
Fixing this is a non-trivial amount of work that will likely have to
wait until the 3.13 window.

To make it easier to iterate on custom BOLT settings, the flags to
pass to instrumentation and application are now defined in configure
and can be overridden by passing `BOLT_INSTRUMENT_FLAGS` and
`BOLT_APPLY_FLAGS`.
indygreg added a commit to indygreg/cpython that referenced this issue May 21, 2023
(This change is a quick and dirty way to merge some of the build system
improvements I'm proposing in pythongh-101093 before the 3.12 feature freeze.
I wanted to scope bloat myself to fix some longstanding deficiencies in
the build system around profile-guided builds. But I'm getting soft
resistance to the reviews so close to the freeze deadline and it is
obvious that we need a simpler solution to hit the 3.12 deadline. While
this change is quick and dirty, it attempts to not make things worse.)

Before this change, we only applied bolt to the main python binary.
After this change, we apply bolt to libpython if it is configured. In
shared library builds, most of the C code is in libpython so it is
critical to apply bolt to libpython to realize bolt benefits.

This change also reworks how bolt instrumentation is applied. It
effectively removes the readelf based logic added in pythongh-101525 and
replaces it with a mechanism that saves a copy of the pre-bolt binary
and restores that copy when necessary. This allows us to perform
bolt optimizations without having to manually delete the output binary
to force a new bolt run.

We also add a new make target for purging bolt files and hook it up
to `clean` so bolt state is purged when appropriate.

`.gitignore` rules have been added to ignore files related to bolt.

Before and after this refactor, `make` will no-op after a previous run.
Both versions should also share common make DAG deficiencies where
targets fail to trigger as often as they need to or can trigger
prematurely in certain scenarios. e.g. after this change you may need
to `rm profile-bolt-stamp` to force a bolt run because there aren't
appropriate non-phony targets for bolt's make target to depend on.
Fixing this is a non-trivial amount of work that will likely have to
wait until the 3.13 window.

To make it easier to iterate on custom BOLT settings, the flags to
pass to instrumentation and application are now defined in configure
and can be overridden by passing `BOLT_INSTRUMENT_FLAGS` and
`BOLT_APPLY_FLAGS`.
erlend-aasland pushed a commit that referenced this issue May 22, 2023
…104709)

Apply BOLT optimizations to libpython for shared builds. Most of the C
code is in libpython so it is critical to apply BOLT there fully realize
BOLT benefits.

This change also reworks how BOLT instrumentation is applied. It
effectively removes the readelf based logic added in gh-101525 and
replaces it with a mechanism that saves a copy of the pre-bolt binary
and restores that copy when necessary. This allows us to perform BOLT
optimizations without having to manually delete the output binary to
force a new bolt run.

Also:
- add a clean-bolt target for purging BOLT files and hook that up to the
  clean target
- .gitignore BOLT related files

Before and after this refactor, `make` will no-op after a previous run.
Both versions should also share common make DAG deficiencies where
targets fail to trigger as often as they need to or can trigger
prematurely in certain scenarios. e.g. after this change you may need to
`rm profile-bolt-stamp` to force a BOLT run because there aren't
appropriate non-phony targets for BOLT's make target to depend on.

To make it easier to iterate on custom BOLT settings, the flags to pass
to instrumentation and application are now defined in configure and can
be overridden by passing BOLT_INSTRUMENT_FLAGS and BOLT_APPLY_FLAGS.
@corona10
Copy link
Member Author

faster-cpython/ideas#598

@iritkatriel iritkatriel added the build The build process and cross-build label Nov 29, 2023
corona10 added a commit to corona10/cpython that referenced this issue May 4, 2024
@corona10
Copy link
Member Author

corona10 commented May 4, 2024

corona10 added a commit to corona10/cpython that referenced this issue Aug 31, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 2, 2024
corona10 added a commit that referenced this issue Sep 2, 2024
…h-118572) (#123601)

gh-101525: Skip test_gdb if the binary is relocated by BOLT. (gh-118572)
(cherry picked from commit f95fc4d)

Co-authored-by: Donghee Na <[email protected]>
corona10 added a commit to corona10/cpython that referenced this issue Sep 2, 2024
corona10 added a commit that referenced this issue Sep 2, 2024
#123603)

[3.12] gh-101525: Skip test_gdb if the binary is relocated by BOLT. (gh-118572)
(cherry picked from commit f95fc4d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build The build process and cross-build performance Performance or resource usage type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants