Skip to content

Allow AsyncSequence operators to be inlined in their construction #38310

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

Merged
merged 1 commit into from
Jul 9, 2021

Conversation

phausler
Copy link
Contributor

@phausler phausler commented Jul 8, 2021

This grants AsyncSequence a huge perf boost for trivial operator application. Locally this benchmarks initially at about 3 million events per second to afterwards over 30 trillion events per second (this is an artificial speed - it is just reflecting the fact that the pipeline now takes zero time since it is already computed due to inlines)!

Previously the compiler could not see past the initialization and so any application of operators were blocked by the initialization of the operator. Now the initialization is visible and consequently the application can be directly inlined into any code-gen for usage.

@phausler
Copy link
Contributor Author

phausler commented Jul 8, 2021

I can add benchmarks for this but it seems that #36908 has not yet been merged.

@phausler
Copy link
Contributor Author

phausler commented Jul 8, 2021

@swift-ci please smoke test

@eeckstein
Copy link
Contributor

This is the PR you'll need for benchmarking: #36923

@phausler phausler force-pushed the phausler/async_sequence_perf branch from 0107671 to bf090b9 Compare July 8, 2021 19:25
@phausler
Copy link
Contributor Author

phausler commented Jul 8, 2021

@swift-ci please smoke test

@bendjones
Copy link
Contributor

LGTM the numbers we spoke about earlier today sound really impressive

@ZevEisenberg
Copy link
Contributor

Can someone ELI5 how a computer running at a few gigahertz (billions of operations per second) could do anything more than a trillion times per second?

@phausler
Copy link
Contributor Author

phausler commented Jul 9, 2021

Can someone ELI5 how a computer running at a few gigahertz (billions of operations per second) could do anything more than a trillion times per second?

the claim actually has to do more with the inline of the code rather than actual operations per second, what is happening is that the compiler can see through the implementation enough that the execution is now just a memcpy and the actual work is zero here. So perhaps the number of trillions is slightly in bad faith - but more so a testament to the amazing optimization this now can enjoy.

@phausler
Copy link
Contributor Author

phausler commented Jul 9, 2021

long/short, any per-item benchmark div-0's ;)

Copy link
Contributor

@aschwaighofer aschwaighofer left a comment

Choose a reason for hiding this comment

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

looks good to me

@phausler phausler merged commit 6a80196 into swiftlang:main Jul 9, 2021
swift-ci pushed a commit that referenced this pull request Oct 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants