A commenter on my code sample for a concurrent skiplist correctly pointed out two errors in the program. I attempted to fix both, but further testing revealed another problem in Release mode (optimized, no debug). One of the thread would suddenly stop. After much screwing around, I discovered that the program was stuck in a spin wait: “while (!goAhead) ;”. I added a volatile declaration to that variable and then the program worked. It turns out the loop keeps reusing the value in the register, rather than reloading the variable when another thread says it’s OK to go.
I’ve put the code in Launchpad and removed it from the other post. You can download it like this using the Bazaar VC tool:
bzr branch lp:~suranap/+junk/concur.net
There’s still a problem with the program. When I run 2 threads, it is really quick. When I run 4 threads, there is so much contention that the “add” method has to retry a zillion times. Of course, my test case is probably extreme. I’ll compare the performance with Java’s implementation to see if it’s in the same league.
August 26, 2009 at 3:54 pm |
[...] Skip List woes By Pinku [ed: I've removed the code. Look here for an explanation and the updated [...]