Skip to content

Implement Write Lock Downgrading #62

Closed
Closed

Description

@orthur2

Currently, if a task holding a write lock finishes modifying data and wants to allow concurrent reads, it must drop the write lock and then re-acquire a read lock. This process is inefficient and can introduce potential race conditions in the time between dropping the write lock and acquiring the read lock.

This was identified as a potential future improvement during the work on PR #61.

This issue proposes adding a downgrade() method to RwLockWriteGuard. This would allow a task to atomically convert an exclusive write lock into a read lock (RwLockReadGuard).This improves performance and throughput by allowing read operations to proceed immediately without contention from other pending write locks.

This is a common and proven feature in other major Rust libraries:

And I would like to work on this issue.

Activity

  1. orthur2 commented on Aug 8, 2025

    @orthur2
    ContributorAuthor

    Hi, @tisonkun , Could I be assigned this issue? Just wanted to gently follow up on this proposal to make sure it wasn't overlooked. Alternatively, should I just go ahead and create a PR directly without an assignment, since this proposal has been discussed before? I'm not sure if you've seen this issue.

  2. tisonkun commented on Aug 8, 2025

    @tisonkun
    Member

    You can directly submit a PR.

    But since you're the issue creator and you spend time on this, based on our previous collaboration, I can assign this issue to you.

    Typically, I seldom assign issue to certain person unless I know he/she would work on it. Otherwise it's no more than a signal that: "Someone has already taken the issue and I should go away". But often the assignee vanishes later and it prevents others to take it over :D

  3. added
    enhancement
    on Aug 8, 2025
  4. orthur2 commented on Aug 8, 2025

    @orthur2
    ContributorAuthor

    You can directly submit a PR.

    But since you're the issue creator and you spend time on this, based on our previous collaboration, I can assign this issue to you.

    Typically, I seldom assign issue to certain person unless I know he/she would work on it. Otherwise it's no more than a signal that: "Someone has already taken the issue and I should go away". But often the assignee vanishes later and it prevents others to take it over :D

    Thank you for the quick reply and for assigning the issue to me. Actually, I noticed you didn't assign the issue last time and suspected it was your usual practice. I just wanted to confirm cautiously since I hadn't heard back yet. I completely understand your philosophy on assignments, and I really appreciate the trust.

    I'll get started on the implementation and will submit a PR when it's ready for review.

  5. tisonkun commented on Aug 30, 2025

    @tisonkun
    Member

    @orthur2 This should be resolved by #65?

  6. orthur2 commented on Aug 30, 2025

    @orthur2
    ContributorAuthor

    @orthur2 This should be resolved by #65?

    Yes, exactly. Since you just merged the fix in #65, we can close this issue now. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions