Re:Unix V5, OpenBSD, Plan 9, FreeBSD, and GNU implementation...
by cpeterso on Tuesday July 19, 2011 @04:04PM
(#2782821)
djb's allocator alloc() does this. He preallocates a 4 KB static buffer before hitting system malloc(). Avoiding the overhead of malloc() is pretty important for the performance of systems like qmail that fork many small processes.
[ Parent
| on HN ]
Re:Unix V5, OpenBSD, Plan 9, FreeBSD, and GNU implementation...
by tedunangst on Tuesday July 19, 2011 @04:56PM
(#2783038)
That's ridiculous. The overhead of fork is about a bajillion times higher than malloc.
Re:Unix V5, OpenBSD, Plan 9, FreeBSD, and GNU implementation...
by adestefan on Tuesday July 19, 2011 @10:40PM
(#2784080)
With a COW fork() I bet it's smaller. I smell a test coming on, but alas it's late here and I'm going to bed.
I'm also guessing that 4k was chosen because a malloc() of 1 page is faster than a malloc() of >1 page. Of course that's with the assumption that the systems use a 4k page size.
Re:Unix V5, OpenBSD, Plan 9, FreeBSD, and GNU implementation...
by aidenn0 on Tuesday July 19, 2011 @08:44PM
(#2783776)
Are you sure? I'd bet it's greater, I'd not bet that it's an order of magnitude better, fork() has been optimized a lot more than brk().
Re:Unix V5, OpenBSD, Plan 9, FreeBSD, and GNU implementation...
by sliverstorm on Tuesday July 19, 2011 @04:42PM
(#2782986)
Many small processes? How many?
4 KB * (many) could be frightening.
Re:Unix V5, OpenBSD, Plan 9, FreeBSD, and GNU implementation...
by jff on Tuesday July 19, 2011 @06:34PM
(#2783436)
If your system has 32,000 processes and you allocate 4 KB to each of them... that's 128 MB. I'm not crapping my pants at that figure because even the oldest machine in my office, an old Thinkpad, has 2 GB of RAM.