Skip to content

Checksum's usage of a native hash algorithm resulting in thread starvation #67995

@davkean

Description

@davkean

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:

  1. Download trace from any run of Speedometer's CopyRichNotAccurate tests (ask me offline for how to do this)
  2. Look at blocked time via Thread Time Stacks under CFinalize::RegisterForFinalization.

image

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    untriagedIssues and PRs which have not yet been triaged by a lead

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions