Improved the way that the stock snap-server backend handles timeouts; before we were using Johan Tibell’s trick of keeping a list of edits to the master threads table behind an IORef , and then applying these edits in a worker thread which runs periodically to kill timed-out connections.

During some benchmark testing we’ve been doing for an upcoming article, we noticed that this approach was still causing too much blackhole contention on the IORef — worker threads were spending too much time fighting over who got to modify the list of edits. In snap-server 0.2.15, we’ve switched to a striped locking scheme, in which we manage a vector of priority search queues, each guarded by a lock. We pick which queue to register with based on the hash of the worker thread’s ThreadId .

In our testing this change has improved throughput by 50% in absolute terms. You can browse the source code for the new module on our github page.