3 ms·
Nice write-up. I've long believed that malloc(4192) == mmap() is a very bad idea for this reason -- in fact, let your heap get giant pages, damn it. Also, for
by cryptonector 6y ago
Nice write-up. I've long believed that malloc(4192) == mmap() is a very bad idea for this reason -- in fact, let your heap get giant pages, damn it. Also, fork() turns out to be pretty evil. fork() is OK when you're forking worker processes very early in a daemon's life, but for most other uses it's just a very bad idea -- use vfork() or posix_spawn() instead.
There are just too many problems with fork(). That paper about vfork() being harmful had it exactly backwards. It is fork() that is harmful. It has safety issues that make using it safely sufficiently hard as to not be worth it in many cases, but the real killer is fork()'s copy semantics, which just kills performance.
(A colleague of mine has used fork() in signal handlers to call abort() on the child side as a way of getting core dumps from live processes without killing them. That's pretty neat, and one of the very few uses of fork() I would endorse.)