Description
Current behavior 😯
There are a few conditions related to build profiles for gitoxide
defined in the top-level Cargo.toml
that seem like they can be addressed when—as planned in the comment discussion in #1475—splitting the release
profile into separate release
and prof
(or profile
or profiling
) profiles.
- Debug symbols - as discussed.
- Unclear intent for LTO -
#lto = "fat"
. - Old plan for optimizations in debug builds.
1. Debug symbols
Currently the release
profile leaves debug symbols in because they are useful for profiling, but this creates the need to strip them in a separate step when they are not wanted, such as when building binaries to publish in releases on GitHub.
This is as discussed in comments in #1475, with a suggested plan in #1475 (comment).
2. Unclear intent for LTO
It is not clear if link-time optimization, at higher than the default very limited level, should be done. It's possible this might even differ between release
and prof
profiles. (This is the main sub-issue that may need examination and discussion, and the main reason I opened this issue.)
Early on, in 07859cb, various performance-related configuration was set for the release
profile. This included the most aggressive link-time optimization available—short of LTO across different languages—which was still in place about a year ago:
https://github.com/Byron/gitoxide/blob/71efcbba112376b4acaf37d662cdb38d369462be/Cargo.toml#L185
Then in bd32e39 (#893) it was commented out, with the effect of changing the lto
setting from fat
to the default of false
, which somewhat unintuitively still performs link-time optimization, just only within the crate itself.
https://github.com/Byron/gitoxide/blob/1d37bf6a773d56eea9003aa626ced413e8e0eaa3/Cargo.toml#L209
For the last year, it's been that way. Since the gitoxide
project is made up of many crates, which the gitoxide
binary crate itself uses, I suspect this does not leverage most of the benefit of LTO. That is, the word "false
" may be intuitively accurate in this case.
Perhaps benchmarking was done and found LTO not to be helpful for gix
and ein
. (In other software that uses any gitoxide
crates, that software would of course set whatever LTO-related configuration is wanted.) But the commit and PR do not state a reason for the change, and they are otherwise not conceptually related to LTO or optimization. If the goal is to decrease build times, then thin
could be used, which is documented to be almost as good as fat
while being faster to perform.
Another possibility is that LTO was turned off because the resulting optimizations decreased the detail available when profiling or made the results hard to interpret. If that was the reason, then I think that, when splitting release
into release
and prof
, this would be resolved by setting different values of lto
in the two different profiles. release
could have fat
or thin
, while prof
could stick with the default of false
.
3. Old plan for optimizations even in debug builds?
This would not affect the release
or prof
configuration, but I suspect it could be clarified at the same time.
a5b1cd3 added:
https://github.com/Byron/gitoxide/blob/1d37bf6a773d56eea9003aa626ced413e8e0eaa3/Cargo.toml#L217-L219
It seems intuitively odd to compile dependencies with a higher optimization level than the code that is using them, especially since this may make stack traces less rich. On the other hand, maybe it is to make test runs faster.
We are already doing it, with the even more aggressive level of 3
, in the dev
profile for particular dependencies, most of which are even gix-*
crates. This was done in 4a948d0 (after having been attempted in #190 per a22c95b and 85f1a48) with the explicit purpose of making some tests faster. I am not suggesting that this be changed, since its purpose is clear from the commit message and running tests faster has a number of benefits.
https://github.com/Byron/gitoxide/blob/1d37bf6a773d56eea9003aa626ced413e8e0eaa3/Cargo.toml#L196-L205
But one would expect that and the commented-out opt-level = 2
for *
to be right next to each other. Instead, the release
profile is written in between them. Although the commit message in a5b1cd3 makes clear that this was not why that commented-out code was introduced, I wonder if part of the reason it has been preserved as a comment for so long, rather than eventually being uncommented or removed, could be confusion with this other code in the release
configuration:
https://github.com/Byron/gitoxide/blob/1d37bf6a773d56eea9003aa626ced413e8e0eaa3/Cargo.toml#L215
To be clear, I'm not at all advocating changing that, which was introduced in add2e3e (#2) and makes it so dependencies that are only used when building and not used when running the code are not needlessly optimized.
When adding a prof
profile, it would go right next to the release
profile, and having both of them split the two sections that customize dev
profile configuration (doing so even in a related way) would exacerbate the current unclear situation. I'd like to remove whatever is not planned or adjust comments to reflect the goal of code that is wanted for the future but not yet, and then if applicable put the most related things together.
Expected behavior 🤔
See above. It seemed clearer to include this for each subsection.
(I considered opening multiple issues or opening no issue for anything here and just bringing it all up in comments, but I figured this might still be best, even though it goes a bit against the format, because there is at least one other issue related to the comments there, #1478, that should be covered separately and should not be confused with any of this.)
Git behavior
I have not researched this. Some choices of optimization level or the treatment of debug symbols might be illuminating. But the tooling and language are different, and for the upstream Git project, I believe there are no official binary releases. So it seems largely inapplicable.
Steps to reproduce 🕹
Since this is a clarity and release-engineering issue opened for tracking and feedback about things I think are mostly known, reproduction consists mainly of examining the code shown, linked, or otherwise discussed above and in the related portion of the #1475 comment discussion.
One practical note, though: On some platforms, the file
command will reveal debug symbols, including text like "not stripped" in its output when they are present. But it seems the file
command on macOS may not do this.