-
Notifications
You must be signed in to change notification settings - Fork 633
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
Add customization point for scheduling ExecutorJob
s on EventLoop
s
#2538
Merged
FranzBusch
merged 1 commit into
apple:main
from
FranzBusch:fb-serial-executor-performance
Oct 9, 2023
Merged
Add customization point for scheduling ExecutorJob
s on EventLoop
s
#2538
FranzBusch
merged 1 commit into
apple:main
from
FranzBusch:fb-serial-executor-performance
Oct 9, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c36d0ef
to
d43a1db
Compare
glbrntt
reviewed
Oct 9, 2023
c14ee8a
to
b36ad5a
Compare
Lukasa
reviewed
Oct 9, 2023
b36ad5a
to
8e9d701
Compare
b465a7a
to
2ed0c6f
Compare
glbrntt
reviewed
Oct 9, 2023
# Motivation Currently, the NIO's EventLoop conformance to the `SerialExecutor` protocol always uses `execute` to schedule the actual job. However, the closure for `execute` has to close over the job and the `EventLoop` itself; hence, it always allocates. Since jobs are a very fine grained object in Concurrency that are created a lot this lead to millions of allocations in even small benchmarks. # Modification This PR provides a customization point for `EventLoop`s to execute `ExecutorJob`s directly. For `SelectableEventLoop` we store a type erased `UnownedJob` in our `ScheduledTask` and just run it right away. # Result No more allocations when NIO's EL is used as a `SerialExecutor`.
2ed0c6f
to
a945ffd
Compare
glbrntt
approved these changes
Oct 9, 2023
d18277f
to
a945ffd
Compare
Lukasa
approved these changes
Oct 9, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
🔼 needs-minor-version-bump
For PRs that when merged cause a bump of the minor version, ie. 1.x.0 -> 1.(x+1).0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Currently, the NIO's EventLoop conformance to the
SerialExecutor
protocol always usesexecute
to schedule the actual job. However, the closure forexecute
has to close over the job and theEventLoop
itself; hence, it always allocates. Since jobs are a very fine grained object in Concurrency that are created a lot this lead to millions of allocations in even small benchmarks.Modification
This PR provides a customization point for
EventLoop
s to executeExecutorJob
s directly. ForSelectableEventLoop
we store a type erasedUnownedJob
in ourScheduledTask
and just run it right away.Result
No more allocations when NIO's EL is used as a
SerialExecutor
.