Tuesday, October 6, 2009

Locking & Lock Free Collections - Multithreaded Performance

Been exploring Lock-free collections lately, for a highly threaded memory based caching project.

Before I really know how well I'm doing, I need to explore the performance of simpler locking collection classes (simple wrappers around Dictionary, using lock {} and ReaderWriterLockSlim) , as well determine the absolute maximum performance, by testing lockless readonly collections (i.e. read-only operations on pre-filled Dictionary)

1.
So, for the baseline absolute maximum performance, I get approx 55M read operation/sec on a simple Dictinary object, with 10K key/value pairs... this throughput varies little for 4 to 64 parallel threads, on a standard quad-core machine.

2.
I then need tested against a wrapper class, that uses an internal Dictinary, but allows parallel reads, and serialised write access using the ReaderWriterLockSlim class.
100% Reads: 2threads: 5.35M reads/sec, 4threads: 5.12M
reads/sec, 16threads: 4.34M reads/sec, 64threads 3.53M reads/sec

1 comment:

  1. A nice post on this interesting topic.I am not much experienced in this field and could not understand everything in this but I really liked the way you presented this analytically post.
    electronic signature for sharepoint

    ReplyDelete