-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Expose a Lock
type in preview mode
#87672
Conversation
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
Tagging subscribers to this area: @mangod9 Issue Details
API review: #34812
|
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Lock.NativeAot.cs
Outdated
Show resolved
Hide resolved
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Lock.NativeAot.cs
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Threading/Lock.NonNativeAot.cs
Show resolved
Hide resolved
The mono changes look ok. |
Here are some perf numbers on NativeAOT. I used a test that has multiple threads enter a lock, perform a short delay, exit the lock, and perform another short delay. Throughput is the number of enter+delay+exit+delay rounds performed per ms. The delay is a recursive calculation of a random Fibonacci number between 4 and 9. The numbers are from my Intel x64 6-core 12-thread machine on Windows. Using
Using
|
return true; | ||
} | ||
|
||
throw new LockRecursionException(SR.Lock_Enter_LockRecursionException); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I'm following how this gets thrown. It would mean _recursionCount was -1. I don't see a test in LockTests for LockRecursionException.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh - you're using 32 bit overflow like Native AOT .. since this is a new type, how about picking something smaller that is still always going to mean a bug in the app, but small enough that it won't cause a hang in the app (and also becomes feasibly unit testable). Eg., 65K
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in fact that's what the comment suggests "is expected to be high enough that it would typically not be reached when the lock is used properly."
src/libraries/System.Private.CoreLib/src/Resources/Strings.resx
Outdated
Show resolved
Hide resolved
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Lock.NativeAot.cs
Show resolved
Hide resolved
Rebased to fix conflicts |
/azp run runtime-extra-platforms |
Azure Pipelines successfully started running 1 pipeline(s). |
Trying a rebase due to some unrelated build failures. |
The remaining issues in the CI appear to be unrelated. |
This was merged on Red and broke Wasm.Build.Tests on |
Also one of the failures is:
Could this be related to the change here? I have never seen this happen on the tests before. cc @lewing |
Also introduced #94227 |
I have no idea how this PR could cause those failures, apologies if there was a mishap. There are only a few lines of code in this PR that would affect wasm, do you see anything that could be relevant? I'll see if I can get a repro, but otherwise I don't see any link between the failure and this PR.
#94241 should fix the issue. |
Only thing I can think of at the moment is that there is a pragma warning disable for using preview features when we should probably be enabling preview features for the corelib project. I don't know what kind of effect that would have, but I think that's something that was missed after local testing and unaddressed, so I'll fix that anyway. |
- Used the project property instead of disabling the compiler warning. Probably a bit cleaner, and would enable using Lock in other libraries to try it out. - Undid an unnecessary change from dotnet#87672
* Small cleanup for Lock in Mono - Enable preview features in shared CoreLib project instead of disabling the compiler warning. Probably a bit cleaner, and would enable using Lock in other libraries to try it out. - Undid an unnecessary change from #87672
Lock
type requires preview features to be enabledLock
implementation, and fixed a couple of issues.Lock
implementation. The performance of acquiring a lock under contention is improved in NativeAOT.API review: #34812
Tracking issue: #87673