News for hackers. Stuff that matters.
Re:posix-spawn: a faster fork+exec for ruby by Groxx on Thursday March 03, 2011 @09:02PM (#2286633)
Wow, check out the Linux vs OSX graphs. Anyone care to enlighten me as to why they are that different? The worst OSX fork + exec call is more than 2x faster than the fastest fork + exec on Linux, and over 10x faster when the memory increases past ~300MB.

Given that OSX's isn't dependent on page table size, I'm guessing it just always does copy-on-write... but that's a pretty un-knowledgeable guess.

Re:posix-spawn: a faster fork+exec for ruby by tmm1 on Thursday March 03, 2011 @09:33PM (#2286719)
The reason fork is so slow on Linux is because the default page size is 4k. This means for a 300MB process, 76800 page table entries have to be copied during the fork.

There are ways to enable HugeTBL on linux to increase the page size, which can improve fork performance as well. See http://stackoverflow.com/questions/2731531/faster-forking-of..., http://linuxgazette.net/155/krishnakumar.html and http://sourceforge.net/projects/libhugetlbfs/

Does anyone know how fork is implemented on BSD/OSX and why it doesn't exhibit the same characteristics?

Re:posix-spawn: a faster fork+exec for ruby by akent on Thursday March 03, 2011 @09:40PM (#2286744)
BSD / OS X has native support for superpages.

From version 2.6.38, Linux will get native huge page / superpage support too. http://lwn.net/Articles/423584/

Re:posix-spawn: a faster fork+exec for ruby by Andys on Friday March 04, 2011 @04:13AM (#2287536)
In FreeBSD, it is extent-based, so a 300MB process might actually only have a couple dozen maps - heap, stack, program binary, and whatever dynamically loaded libraries.

I'd be shocked if it wasn't the same in linux.