On Sun, Aug 15, 2010 at 12:07 AM, Tim Starling tstarling@wikimedia.org wrote:
He might have shot holes in it if he hadn't suggested it 5 days ago:
<domas> my armchair architect idea was writing to some cyclical shared buffer <domas> and allowing other threads to pick stuff from it
The tricky thing would be efficiently synchronising updates to the queue, so that reads and writes are atomic. You wouldn't need to do many syscalls in the main thread to make it slower than the current version.
Have one circular buffer per write thread. The pointer to the front of each buffer would only be written by the thread that writes to that buffer, after it's written the new entry to the buffer. The pointer to the back would only be written by the one thread that reads all the buffers. Since each pointer is a single word long and is only written to by a single thread, no locks are needed anywhere, and no more syscalls than at present.