Zefram via RT <perlbug-followup@perl.org> wrote: > via RT wrote: > >In my attached example (vfork.perl) using Inline::C, it only takes > >around 3 seconds to vfork+execve+waitpid "/bin/true" 10000 times > >on my system. With the Perl CORE::system() function, it takes > >11-12 seconds(!). > > This is not a fair comparison. You should compare standard CORE::system() > against an equivalent implementation of the system op that uses vfork > instead of fork, because that's the change that you're proposing we > should make. Oops, missed the pipe creation and probably a few other things system() does. I tried dumbly swapping out fork() for vfork() in the perl sources but of course that doesn't work, yet: the child process is modifying its heap in several places and probably doing other vfork-incompatible things. I still haven't had time to digest and learn much about the perl internals; but I figured I'd start with a wishlist report to get things started. Anyways, attached is a tiny standalone C program with most error-checking omitted. I've only tested it on Debian GNU/Linux but hopefully it runs on most POSIX-like systems with vfork. $ gcc -o vfork-test -Wall -O2 vfork-test.c $ time ./vfork-test : normal fork() real 0m6.444s user 0m0.023s sys 0m1.713s $ time ./vfork-test vfork real 0m2.725s user 0m0.013s sys 0m0.243s That's only with 10M malloc-ed, increasing the malloc-ed size will show vfork performance remains stable as process size increases. Anyways, I hope the above numbers are convincing enough to have somebody more familiar than I to change Perl to use vfork instead of fork whenever possible. Thank you.Thread Previous