-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Improve the concurrency of erts_fun_table insertions #8662
Conversation
CT Test Results 3 files 141 suites 50m 18s ⏱️ For more details on these failures, see this check. Results for commit 903a647. ♻️ This comment has been updated with latest results. To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass. See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally. Artifacts// Erlang/OTP Github Action Bot |
We have a simple test-case that demonstrates the contention effect.
Here are the baseline results
And here are the results with this patch applied
We have also verified that the |
Thanks for the PR! Can you rebase this to |
903a647
to
d937e6b
Compare
While the erts_fun_table is protected by a read-write lock, when ensuring a fun, the runtime always acquires a writer lock allowing it to insert if the lookup fails. This has the undesirable effect of serializing the insertions even in the degenerate case where the fun is already present and the table does not need to be modified. This change uses a reader lock initially to offer more concurrency in the case where the fun is present, which can be a common case for applications that repeatedly transmit essentially the same fun objects between nodes. If the lookup fails, the code behaves as it did before and falls back to acquiring a writer lock and doing a lookup and insert as needed.
a712e56
to
1cffbf6
Compare
Sorry, I accidentally deleted the remote branch. I have put together #8664 with the same content. |
While the erts_fun_table is protected by a read-write lock but, when inserting a fun, the runtime always acquires a writer lock allowing it to insert if the lookup fails. This has the undesirable effect of serializing the insertions even in the degenerate case where the fun is already present and the table does not need to be modified.
This change uses a reader lock initially to offer more concurrency in the case where the fun is present, which can be a common case for applications that repeatedly transmit essentially the same fun objects between nodes. If the lookup fails, the code behaves as it did before and falls back to acquiring a writer lock and doing a lookup and insert as needed.