-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
Inline project methods #74
Conversation
Thanks for the PR! It is not clear that it is always reasonable to do this, since a large number of inline attributes will affect compile time (e.g., see rust-lang/hashbrown#119) Also, if you want to fully inline project_replace without LTO, the inline attribute may also be needed for private types in pin-project-lite. In any case, please provide specific data on what this will improve. (generated asm1, reproducible benchmarks, etc.) Footnotes
|
8147ab9
to
7658229
Compare
7658229
to
5ebf692
Compare
Here is my attempt at comparing the effect of inlining: https://github.com/EFanZh/pin-project-lite/tree/compare-inlining. (Sorry for not using godbolt, I couldn’t figure out how to patch Under
You can see Also, I have tested the effects of
These examples are handcrafted by me, maybe it’s better to test on a real project. But I don’t know any suitable projects that uses |
I tested this patch on tokio-console with this branch: https://github.com/EFanZh/console/tree/compare-inlining-pin-project-methods. Here is the binary sizes comparison:
Currently, I have only tested binary size changes. @taiki-e do you need other tests? For example: runtime performance benchmarks? |
Hi @taiki-e: Is there anything I can do to get this PR merged? |
Sorry for the late reply. And thanks for the investigation. Assuming there is no impact on compile time, the effects of this all appear to be positive. As for compile time, @nnethercote previously measured it by building async-std (#71). That said, I'm not sure if building the library is the right way to measure the impact of |
Again, I have tested the compile time of tokio-console using this bash script: #!/bin/bash -e
benchmark() {
target_report=$1
shift
cargo clean
cargo fetch "$@"
cargo build --release --timings "$@"
mv 'target/cargo-timings/cargo-timing.html' "$target_report"
}
patching_args=(
--config 'patch.crates-io.pin-project-lite.git="https://github.com/EFanZh/pin-project-lite"' \
--config 'patch.crates-io.pin-project-lite.rev="5ebf6921de62887572fa4e0477e725567de176df"'
)
for opt_level in '"z"' '3'; do
for lto in 'off' 'thin' 'fat'; do
for codegen_units in '16' '1'; do
base_args=(
--config "profile.release.opt-level=$opt_level"
--config "profile.release.lto=\"$lto\""
--config "profile.release.codegen-units=$codegen_units"
)
report_base_name="opt_level=${opt_level//\"/} lto=$lto codegen_units=$codegen_units"
benchmark "$report_base_name - original.html" "${base_args[@]}"
benchmark "$report_base_name - patched.html" "${base_args[@]}" "${patching_args[@]}"
done
done
done Here is my test result:
I didn’t see significant compile time change for this change. |
Published in v0.2.10. Thanks @EFanZh. |
Sometime these methods are not inline under
opt-level=z
compile option, forcing inlining could be beneficial for performance and binary size.