-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
Version Used:
Investigating thread starvation in Speedometer's CopyRichNotAccurate, I see Checksum's usage of CAPI SHA256 hash algorithm is one of the cause of the starvations. It appears the following code path instantiates large number of finalizable objects (ie the underlying SafeHandle) on multiple threads at the same in a short burst. This hits a lock in the CLR's CFinalize::RegisterForFinalization causing contention and resulting in a lot of blocked time on the thread pool, 10% of the blocked time on these threads is this bug.
Steps to Reproduce:
- Download trace from any run of Speedometer's CopyRichNotAccurate tests (ask me offline for how to do this)
- Look at blocked time via Thread Time Stacks under CFinalize::RegisterForFinalization.
I had a look at SHA265Cng and it has a similar path so is likely not the path forward. Maybe the managed version of the algorithm? Or alternative, a custom wrapper around CNG that avoids creating a finalizable safe handle over and over again?
