* process.c (retry_fork_async_signal_safe): Use vfork() if available.
vfork() is still faster than fork() especially when the parent process uses big memory. ruby -rbenchmark -e 'a = "a" * 1_000_000_000; puts Benchmark.measure { system("true") }' fork: 0.000000 0.010000 0.010000 ( 0.014968) vfork: 0.000000 0.000000 0.000000 ( 0.000912) on Debian sid. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
51ee0a634e
commit
9b16f90692
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
|||||||
|
Wed Sep 3 12:05:17 2014 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* process.c (retry_fork_async_signal_safe): Use vfork() if available.
|
||||||
|
vfork() is still faster than fork() especially when the parent
|
||||||
|
process uses big memory.
|
||||||
|
|
||||||
|
ruby -rbenchmark -e 'a = "a" * 1_000_000_000; puts Benchmark.measure { system("true") }'
|
||||||
|
fork: 0.000000 0.010000 0.010000 ( 0.014968)
|
||||||
|
vfork: 0.000000 0.000000 0.000000 ( 0.000912)
|
||||||
|
on Debian sid.
|
||||||
|
|
||||||
Wed Sep 3 11:33:08 2014 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
|
Wed Sep 3 11:33:08 2014 SHIBATA Hiroshi <shibata.hiroshi@gmail.com>
|
||||||
|
|
||||||
* test/openssl/test_pkey_rsa.rb (OpenSSL#test_sign_verify_memory_leak):
|
* test/openssl/test_pkey_rsa.rb (OpenSSL#test_sign_verify_memory_leak):
|
||||||
|
@ -50,6 +50,9 @@
|
|||||||
#ifdef HAVE_SYS_RESOURCE_H
|
#ifdef HAVE_SYS_RESOURCE_H
|
||||||
# include <sys/resource.h>
|
# include <sys/resource.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_VFORK_H
|
||||||
|
# include <vfork.h>
|
||||||
|
#endif
|
||||||
#ifdef HAVE_SYS_PARAM_H
|
#ifdef HAVE_SYS_PARAM_H
|
||||||
# include <sys/param.h>
|
# include <sys/param.h>
|
||||||
#endif
|
#endif
|
||||||
@ -3291,7 +3294,11 @@ retry_fork_async_signal_safe(int *status, int *ep,
|
|||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
prefork();
|
prefork();
|
||||||
|
#ifdef HAVE_WORKING_VFORK
|
||||||
|
pid = vfork();
|
||||||
|
#else
|
||||||
pid = fork();
|
pid = fork();
|
||||||
|
#endif
|
||||||
if (pid == 0) {/* fork succeed, child process */
|
if (pid == 0) {/* fork succeed, child process */
|
||||||
int ret;
|
int ret;
|
||||||
forked_child = 1;
|
forked_child = 1;
|
||||||
@ -3305,6 +3312,7 @@ retry_fork_async_signal_safe(int *status, int *ep,
|
|||||||
_exit(127);
|
_exit(127);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
forked_child = 0; /* for vfork(). */
|
||||||
if (0 < pid) /* fork succeed, parent process */
|
if (0 < pid) /* fork succeed, parent process */
|
||||||
return pid;
|
return pid;
|
||||||
/* fork failed */
|
/* fork failed */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user