[openssl.org #1378] Contribution: twopipe patch for speed test
in my opinion, there is a problem with the -multi option of "openssl
speed". While it works fine for small numbers, it does not work as
expected for larger numbers: When I specify "-multi 128", the speed
program forks 128 child processes which all start working immediately.
However, after a number of childs have been forked (let's say 50), there
are already #(childs forked)+1 (e.g. 51) processes competing for the
CPU. Thus, the father process will not be able to fork all the processes
quickly enough, but rather takes a long period. The consequence is, that
several encryption processes seem to finish even before the last one was
forked (at least for the default interval of 3 seconds). Thus, there are
never 128 processes at once, whereas the very first and the very last
child processes will deliver the best results.
To change this, my patch makes apps/speed.c use the second pipe created
at forking the child processes for each child (hence the name). After
forking, the child executes a read(), waiting for input on the pipe from
the father process. After the father forked all childs, it has to write
one byte of data per child process to make the child active, which is
rather quick compared to forking. In order to avoid race conditions,
I've added a sleep() to the father process which ensures that all childs
will be listening on the pipe before sending the starting signal from
the father process.
I find this patch useful and I want to make it available to other users.
To use it you can apply it with "patch -p0 < twopipe.patch" from the
root of the source directory. After this, you must set -DJS_TWOPIPE for
gcc to enable the patch. Without this flag nothing is changed. If you
are interested in more verbose output, you can also use
-DJS_TWOPIPE_VERBOSE, which automatically adds -DJS_TWOPIPE as well.
I've tested it with 0.9.7a, 0.9.7d, 0.9.7j, and the current CVS release.
If you've any comments please mail me.
OpenSSL Project [url]http://www.openssl.org[/url]
Development Mailing List [email]firstname.lastname@example.org[/email]
Automated List Manager [email]email@example.com[/email]