Lock Free
I just ran my OpenSSL echo server test harness and ran the server under the deadlock tool. The results are interesting and show that the main source of lock contention on the server is for the lock that protects the buffer allocator. Every read or write requires a buffer to be allocated and released. The SSL server actually requires more than one buffer for each read and write as passing the data through the SSL connector causes further buffer allocations. Way back when we first started developing our server framework I boosted the performance quite a bit by having the buffer allocator maintain a pool of buffers rather than allocating and freeing a buffer each time it’s asked. I think we can probably improve the performance even more by switching to lock free list implementation… Only more detailed profiling will tell for sure but it’s certainly something I’ve added to the list of things to do…
I first looked at lock free algorithms for socket list management quite a while ago. At the time we managed to achieve our performance goals without needing them; plus, due to the design of the code at the time, it would have been difficult to plug in a lock free allocator rather than the existing allocator and the lock free implementations that I found weren’t necessarily going to be as portable as I needed.
Now that the code has been refactored several times we have many more interfaces breaking the coupling and it should be possible to slip in an alternative buffer allocation strategy relatively easily.
The following are today’s list of useful lock free links.
-
Ross Bencina provides a very useful review of available material.
-
The Microsoft SList API looks like it might be useful…
-
A paper that explains how lock free LIFOs and FIFOs can be implemented.
-
A lock free LIFO that’s used in MidiShare.