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

Improve the concurrency of erts_fun_table insertions #8664

Merged
merged 1 commit into from
Aug 9, 2024

Conversation

lexprfuncall
Copy link
Contributor

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.

Copy link
Contributor

github-actions bot commented Jul 12, 2024

CT Test Results

    3 files    143 suites   49m 7s ⏱️
1 591 tests 1 542 ✅ 49 💤 0 ❌
2 330 runs  2 256 ✅ 74 💤 0 ❌

Results for commit e8471fa.

♻️ 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

@jhogberg jhogberg added team:VM Assigned to OTP team VM testing currently being tested, tag is used by OTP internal CI labels Jul 15, 2024
@jhogberg jhogberg self-assigned this Jul 15, 2024
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.
@lexprfuncall lexprfuncall force-pushed the fun-tab-concurrency-fix branch from 17ebdbf to e8471fa Compare August 8, 2024 02:55
@jhogberg jhogberg merged commit 64ed48a into erlang:maint Aug 9, 2024
17 checks passed
@jhogberg
Copy link
Contributor

jhogberg commented Aug 9, 2024

Merged, thanks for the PR!

@itssundeep
Copy link
Contributor

Can we also merge this to maint_27.

@jhogberg
Copy link
Contributor

It has already been merged into the maint branch, which means it will be released in "the next minor release on the current version." In this case 27.1 which is planned for mid/late September.

maint-27 is for emergency bug fixes on the 27 track.

@lexprfuncall lexprfuncall deleted the fun-tab-concurrency-fix branch September 4, 2024 02:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team:VM Assigned to OTP team VM testing currently being tested, tag is used by OTP internal CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants