# nt a better summary of heap statistics.
# Sort objects by retained heap. In other words, some tools can tell you the memory usage of an object and all other objects that are referenced by it, as well as list the objects referenced by other objects. This makes it much faster to diagnose the cause of a memory leak.

"This results in an increase from 500 requests/sec to 7000 requests/sec when using Sinatra+Thin+Epoll+Threads. That is pretty ill." -- Joe Damato

On top of all that, this patch helps with Ruby’s green threads, too. If the epoll_wait causes a Ruby event to fire and that event creates a Ruby thread, that Ruby thread gets an entire copy of the existing stack. Each time that thread is switched into and out of, that thread stack has to be memcpy’d into and out of place. Reducing those memcpys by ~800,000 bytes is a HUGE performance win. Want to learn more about threading implementations? Check out my threading models post: here.
Fixing this turned out to be pretty simple. A six (6!!) line patch:
* Speeds up GC by 2-3x because of the huge decrease in stack frame size.
* Fixes an open bug in EventMachine where using threads with Epoll causes lots of slowness. The reason is that each thread will inherit an ~800,000 byte stack that gets copied in and out every context switch.
* This results in an increase from 500 requests/sec to 7000 requests/sec when using Sinatra+Thin+Epoll+Threads. That is pretty ill.

l in all, a productive debugging session lasting about an hour. The result was a simple patch, with 2 big performance improvements.

In this interview filmed during QCon London 2008, Joe Armstrong, designer of Erlang, speaks on various aspects of the Erlang language, presenting its roots, how it compares with other languages and why it has become popular these days due to its native ability to scale on multi core systems.