Skip to content

Use a ReaderWriterLockSlim in RcwCache #117792

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

Merged
merged 1 commit into from
Jul 18, 2025

Conversation

jkoritzinsky
Copy link
Member

This should fix #117775

@Copilot Copilot AI review requested due to automatic review settings July 17, 2025 22:15
@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Jul 17, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR replaces the Lock implementation with a ReaderWriterLockSlim in the RcwCache class to address concurrency issues reported in GitHub issue #117775. The change aims to improve thread safety by providing appropriate read/write locking semantics for cache operations.

Key changes:

  • Replace Lock with ReaderWriterLockSlim for better read/write concurrency control
  • Update method synchronization to use appropriate read/write locks based on operation type
  • Convert from lock statements to explicit lock acquisition with proper try/finally blocks

@jkoritzinsky
Copy link
Member Author

@MihuBot benchmark Interop.ComWrappersTests.ParallelRCWLookUp

Copy link
Contributor

Tagging subscribers to this area: @dotnet/interop-contrib
See info in area-owners.md if you want to be subscribed.

@MihaZupan
Copy link
Member

The bot uses an allow list for running commands, added you now.

Method Toolchain Mean Error Ratio Allocated Alloc Ratio
ParallelRCWLookUp Main 395.9 ms 8.10 ms 1.00 1.66 KB 1.00
ParallelRCWLookUp PR 209.1 ms 2.94 ms 0.53 1.66 KB 1.00

@jkoritzinsky
Copy link
Member Author

Looks like this fixes the regression!

Thanks @MihaZupan for adding me to the allow-list!

@jkoritzinsky
Copy link
Member Author

/ba-g timeouts

@jkoritzinsky jkoritzinsky enabled auto-merge (squash) July 18, 2025 16:44
@jkoritzinsky jkoritzinsky merged commit a074813 into dotnet:main Jul 18, 2025
135 of 147 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Perf] Windows/x64: Regression in RCWLookup on 5/10/2025 5:16:10 PM +00:00
3 participants