| www.delorie.com/archives/browse.cgi | search |
| X-Recipient: | archive-cygwin AT delorie DOT com |
| X-SWARE-Spam-Status: | No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS |
| X-Spam-Check-By: | sourceware.org |
| Message-ID: | <2b113761fca8acd2a86179e108c83c6a.squirrel@dancol.org> |
| Date: | Tue, 3 Jan 2012 14:25:28 -0800 |
| Subject: | Efficient posix_spawn implementation for Cygwin |
| From: | dancol AT dancol DOT org |
| To: | cygwin AT cygwin DOT com |
| User-Agent: | SquirrelMail/1.4.21 |
| MIME-Version: | 1.0 |
| X-IsSubscribed: | yes |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Id: | <cygwin.cygwin.com> |
| List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
| List-Archive: | <http://sourceware.org/ml/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
| Sender: | cygwin-owner AT cygwin DOT com |
| Mail-Followup-To: | cygwin AT cygwin DOT com |
| Delivered-To: | mailing list cygwin AT cygwin DOT com |
posix_spawn [1] is an optional POSIX facility that allows programs to
start other programs without using fork or vfork. I've created an
efficient implementation of posix_spawn for Cygwin. The code is available
at https://github.com/dcolascione/cygspawn.
This library uses Cygwin's nonstandard spawn* family calls in process.h to
provide the full suite of posix_spawn* functionality. Implementing
posix_spawn in terms of spawn turns out to be non-trivial. Nevertheless,
using posix_spawn can improve process startup performance considerably,
especially for large programs:
+ env ITER=1000 JUNKBYTES=209715200 ./testspawn true
real 0m5.179s
user 0m1.550s
sys 0m2.661s
+ env ITER=1000 JUNKBYTES=209715200 ./testfork true
real 1m57.523s
user 0m3.049s
sys 1m52.339s
(JUNKBYTES here tells both programs to malloc 200MB of private data before
doing anything else; this allocation simulates the working set of a large
program.)
Hopefully, it will be more feasible to add posix_spawn support to other
projects than to add Cygwin-specific cases for direct calls to spawn.
posix_spawn is natively supported on OS X, and gnulib provides an
implementation in terms of fork or vfork for all other common platforms.
One example: Emacs is an example of a large program that routinely runs
subprocesses. In my case, fork latency was so great that I had to disable
Emacs' support for version control integration: I didn't want to wait for
two seconds after opening a new file while Emacs queried the . I'm working
on adding support to posix_spawn to Emacs [2]; when it works, I'll be able
to use the built-in version control integration under Cygwin just like I
do on other Unix systems.
[1] http://pubs.opengroup.org/onlinepubs/009695399/functions/posix_spawn.html
[2] https://github.com/dcolascione/emacs/tree/cygw32
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |