Just noticed Hammerspace
Really interesting solution for storing translations out of Ruby HEAP and yet make them available via simple Ruby hash like interface without involving network or any kind of Socket IO.
It uses sparkey for heavy lifting though.
Epoll Oneshot
When using non-blocking IO to build high performance servers one problem people face is, how to leverage multiple cores available on machine to even speed things up further.
Usually people come with following solutions
-
Run polling loop in one thread and have a thread pool for off loading long running processes. No IO is ever performed into polling thread from thread pool threads though and hence has limited scalability.
-
Another approach is have two separate selectors for Read and writes and hence two different threads. But this requires careful locking because often you want to observe read or write events on same file descriptor.
-
EPOLLONESHOT is another approach (which I learnt today morning) which solves this problem elegantly. What it does is - when you add a file descriptor to monitoring list via
epoll_ctl
you set this flag. And when this file descriptor is ready with an event (either read, write or connect) then the file descriptor is automatically disabled for further notifications until it is added back viaepoll_ctl
again.
This allows multiple threads to process events returned by epoll_wait
because only one thread
will ever receive a file descriptor. More details is explained in this stack overflow thread - http://stackoverflow.com/questions/5541054/how-to-correctly-read-data-when-using-epoll-wait