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

Refactor async_rw_mutex #1379

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

msimberg
Copy link
Contributor

@msimberg msimberg commented Dec 19, 2024

This is an attempt at slightly simplifying and optimizing the internals of async_rw_mutex. This avoids the needs for a lock to keep track of continuations and instead triggers continuations through operation states. The continuations are linked to each other through an intrusive linked list of operation states. These changes also avoid the need to have a weak shared pointer between shared states.

Overall I'm hoping that the removal of extra reference counting and locks will slightly improve performance, but fundamentally the structure is still the same, requiring the same amount of dynamic allocations (cf. #1125; this PR does not address that) as before (in fact, one more allocation for the value stored by the mutex). So the impact may be minimal in terms of performance. However, I'm also making these changes to make the dependency triggering a bit more understandable.

I'm opening this for testing, but it's far from ready for merging. It still needs:

  • Some words on the internals of async_rw_mutex, how are triggers continuations etc. Ideally with some diagrams as well.
  • Reduce duplication of internals. Many helper functions and type definitions are duplicated for the void and non-void cases.
  • Benchmarks, both in pika and DLA-Future.
  • Avoid exposing the allocator in all templates?
  • Relax memory orderings?
  • Reshuffle class members for better access patterns?

This allows avoiding synchronization required when passing the value from one shared state to another.
Use the shared state already stored in the operation state in continuations.
…hared state

Don't do it in the previous shared state, for simpler reasoning about ownership.
@msimberg msimberg self-assigned this Dec 19, 2024
Copy link

codacy-production bot commented Dec 19, 2024

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
-0.02% (target: -1.00%) 92.79% (target: 90.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (07e3e5b) 18217 13756 75.51%
Head commit (6def689) 18227 (+10) 13759 (+3) 75.49% (-0.02%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#1379) 111 103 92.79%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

1 participant