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

Reduce LLVM code generation #5859

Merged
merged 17 commits into from Jul 15, 2023
Merged

Reduce LLVM code generation #5859

merged 17 commits into from Jul 15, 2023

Conversation

dullbananas
Copy link
Contributor

This reduces the amount of LLVM code generated, which is helpful for compilation speed.

Motivation

A big portion of LLVM code generation for Lemmy server is caused by a few Tokio functions: cargo llvm-lines output

It would be helpful to reduce this because it contributes to Lemmy's extremely slow compilation.

Solution

Split parts of functions into separate functions without unneeded generic parameters: https://nnethercote.github.io/perf-book/compile-times.html#llvm-ir

@github-actions github-actions bot added the R-loom Run loom tests on this PR label Jul 11, 2023
@Darksonn Darksonn added A-tokio Area: The main tokio crate M-task Module: tokio/task labels Jul 11, 2023
@Darksonn
Copy link
Contributor

The current changes look good to me. Since this is marked as a draft, is there anything else you would like to change?

Copy link
Member

@hawkw hawkw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks good to me!

i wonder if there are other places in the codebase where a function is monomorphized over multiple type parameters but only needs to be monomorphized over one of them. of course, code that's generated per-future is almost certainly the biggest culprit in terms of build time...

@dullbananas dullbananas marked this pull request as ready for review July 12, 2023 20:15
@dullbananas
Copy link
Contributor Author

It's now ready to merge

Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks reasonable enough. These all reduce codegen according to a benchmark you did?

tokio/src/runtime/task/harness.rs Outdated Show resolved Hide resolved
Co-authored-by: Alice Ryhl <aliceryhl@google.com>
@dullbananas
Copy link
Contributor Author

It looks reasonable enough. These all reduce codegen according to a benchmark you did?

It decreases total LLVM lines in Lemmy by 8.5%

@Darksonn Darksonn merged commit 304d140 into tokio-rs:master Jul 15, 2023
75 checks passed
@Darksonn
Copy link
Contributor

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate M-task Module: tokio/task R-loom Run loom tests on this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants