Skip to content

Consider replacing SynchronizedDictionary with ConcurrentDictionary #743

Description

@Youssef1313

I think the BCL ConcurrentDictionary should be able to perform much better than the current SynchronizedDictionary implementation.

Using Moq, which depends on Castle.Core, I observe threadpool starvation in a parallelized test run. The threadpool threads are mostly in stack traces similar to this one:

Image
  • Using ConcurrentDictionary might lock less. I guess it creates some buckets per the hash code, and the different buckets get different locks, which allows for more concurrent access without breaking the type's thread safety.
  • Or, if you have other approaches where you can eliminate the need to lock altogether, that also might be a good option.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions