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
|
|
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.
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.
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.
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."
|
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. |
* 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
Locktype requires preview features to be enabledLockimplementation, and fixed a couple of issues.Lockimplementation. The performance of acquiring a lock under contention is improved in NativeAOT.API review: #34812
Tracking issue: #87673