-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
SBLK_MASK_LOCK_THREADID allow tid up to 65535 #88772
SBLK_MASK_LOCK_THREADID allow tid up to 65535 #88772
Conversation
@jkotas, can you please take a look and see if there will be problems if we increase the number of bits used for thread id? |
How many threads does the workload in question have? This change is only going to help if it has more than 1000 threads. If the syncblocks are created for other reasons, it is not going to help. |
Note that this is not exactly about simultaneous number of threads, but about the highest thread ID that a thread can have. Thread pool often runs number of threads that is more than number of cores. And a high-end machine may have hundreds of logical cores this days, so 1024+ threads seems possible. But also, there is some latency in thread termination and ID recycling. It may be possible for a few threads after a burst of activity to get IDs higher than 1024 even if you did not have this many threads at the same time, so you may not need a very "high-end" machine, to see this. Once you get threads with an ID >= 1024, they will inflate every thin lock that they use. 65535 may be enough for some time, so this is a reasonable change. |
For the syncblocks to become a problem you'd also need to lock on a large number of objects. There are other reasons for syncblocks, though - like COM interop. |
the reason why Andrew asked the question is because while this is not a problem on its own, we wanted to make sure we are not robbing other things of using these bits, eg, if this means something else will have 6 fewer bits to use, that's not good. but if when the bits are being used for locking, nothing else will share these 32 bit anyway (ie, those 6 bits wouldn't be used anyway), then it doesn't affect anything else. if anyone has the answer to that question that'd be really helpful. last time I looked at the code for who uses these bits was ages ago so I don't remember the details. |
On CoreCLR the sync word has 10 bits that are not used for anything right now. |
Well, that is not entirely correct. That is true when object header is used for locking. |
thanks for the info, @VSadov! we are doing some investigation on our side to see what exactly the culprit of the perf problem was, so please do not merge this for the time being while we are doing that. |
@cshung and I talked offline and concluded that this is a reasonable fix. |
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.
LGTM. Thanks!
* SBLK_MASK_LOCK_THREADID allow tid up to 65535 * copy comment from NativeAOT ObjectHeader.cs --------- Co-authored-by: dickens <[email protected]>
* SBLK_MASK_LOCK_THREADID allow tid up to 65535 * copy comment from NativeAOT ObjectHeader.cs --------- Co-authored-by: DIcKeNs <[email protected]> Co-authored-by: dickens <[email protected]>
This is an attempt to fix #88426 by avoiding sync block creation.
All test failures are known and is unrelated to the change.
@dotnet/gc