Re: WinAPI spawn() not used by Cygwin posix_spawn()? Re: [PATCH] Cygwin: Add spawn family of functions to docs

2025-02-17 Thread Jeremy Drake via Cygwin-patches
On Mon, 17 Feb 2025, Corinna Vinschen wrote:

> The requirements of posix_spawn and their helper functions are so
> that we can't easily fulfill them without doing the fork/exec
> twist.
>
> See https://man7.org/linux/man-pages/man3/posix_spawn.3.html.
> Windows CreateProcess() is not quite the same as Linux clone().
>
> However, if you think you can come up with a version only running the
> spawnve function and thus speed up Cygwin, feel free to send patches.

(based on my recollections rather than actually reading the docs again...)
Specifically, maybe the case where the attributes which are supposed to do
things effectively between fork and exec are not set could be fast-pathed
to use spawn/CreateProcess, and the more complex cases fall back to
fork/exec.  If the created process is also a Cygwin process, perhaps the
actions that are supposed to happen between fork and exec could happen in
the startup code (much like fork emulation).

Just brainstorming.

BTW, I vaguely remember an issue with GNU make in MSYS2, where we found
that making it *not* use posix_spawn made it faster.
https://github.com/msys2/MSYS2-packages/blob/a0902f1e21781022c5ceca44c64190998a62e048/make/PKGBUILD#L31-L32



Re: WinAPI spawn() not used by Cygwin posix_spawn()? Re: [PATCH] Cygwin: Add spawn family of functions to docs

2025-02-17 Thread Lionel Cons
On Mon, 17 Feb 2025 at 11:08, Corinna Vinschen via Cygwin
 wrote:
>
> On Feb 16 23:33, Lionel Cons via Cygwin wrote:
> > On Sun, 16 Feb 2025 at 22:47, Mark Geisert  wrote:
> > >
> > > In the doc tree, change the title of section "Other UNIX system
> > > interfaces..." to "Other system interfaces...".  Add the spawn family of
> > > functions noting their origin as Windows.
> >
> > re spawn() family: Cygwin posix_spawn() seems to rely on the rather
> > inefficient vfork(), while Opengroup intended it to be an API to
> > Windows spawn().
> >
> > Is there a technical limitation why Cygwin posix_spawn() cannot use
> > WinAPI spawn() directly?
>
> The requirements of posix_spawn and their helper functions are so
> that we can't easily fulfill them without doing the fork/exec
> twist.

How did UWIN do that? I did ask around - Glenn Fowler of AT&T Research
demonstrated a prototype of UWIN posix_spawn() before posix_spawn()
was finalised by the Austin Group as Opengroup POSIX standard. So this
IS possible, and because non fork() or page cloning has to be done it
should be significantly faster than the
fork()-and-throw-copied-data-away-at-exec() approach.

> See https://man7.org/linux/man-pages/man3/posix_spawn.3.html.> Windows 
> CreateProcess() is not quite the same as Linux clone().

Here might be the misunderstanding:
posix_spawn() is intended NOT to copy anything except the file
descriptors and requested attributes, no memory pages and no
whatsoever. Everything should be done on the caller's process side,
nothing in the child process.

Lionel


Re: [PATCH] Cygwin: Add spawn family of functions to docs

2025-02-17 Thread Corinna Vinschen
On Feb 16 13:46, Mark Geisert wrote:
> In the doc tree, change the title of section "Other UNIX system
> interfaces..." to "Other system interfaces...".  Add the spawn family of
> functions noting their origin as Windows.
> 
> The title change seems warranted as neither the spawn family of
> functions nor the listed clock_setres() function originated from UNIX
> systems.
> 
> ---
>  winsup/doc/posix.xml | 11 ++-
>  1 file changed, 10 insertions(+), 1 deletion(-)

Yeah, this is probably the right thing to do.  I'm jsut waiting
for Brian in terms of the POSIX doc update.  That's why I wait with
the eaccess and acl functions as well.


Thanks,
Corinna


Re: WinAPI spawn() not used by Cygwin posix_spawn()? Re: [PATCH] Cygwin: Add spawn family of functions to docs

2025-02-17 Thread Corinna Vinschen
On Feb 16 23:33, Lionel Cons via Cygwin wrote:
> On Sun, 16 Feb 2025 at 22:47, Mark Geisert  wrote:
> >
> > In the doc tree, change the title of section "Other UNIX system
> > interfaces..." to "Other system interfaces...".  Add the spawn family of
> > functions noting their origin as Windows.
> 
> re spawn() family: Cygwin posix_spawn() seems to rely on the rather
> inefficient vfork(), while Opengroup intended it to be an API to
> Windows spawn().
> 
> Is there a technical limitation why Cygwin posix_spawn() cannot use
> WinAPI spawn() directly?

The requirements of posix_spawn and their helper functions are so
that we can't easily fulfill them without doing the fork/exec
twist.

See https://man7.org/linux/man-pages/man3/posix_spawn.3.html.
Windows CreateProcess() is not quite the same as Linux clone().

However, if you think you can come up with a version only running the
spawnve function and thus speed up Cygwin, feel free to send patches.


Corinna


Re: [PATCH] Cygwin: Add spawn family of functions to docs

2025-02-17 Thread Brian Inglis

On 2025-02-17 03:22, Corinna Vinschen wrote:

On Feb 16 13:46, Mark Geisert wrote:

In the doc tree, change the title of section "Other UNIX system
interfaces..." to "Other system interfaces...".  Add the spawn family of
functions noting their origin as Windows.

The title change seems warranted as neither the spawn family of
functions nor the listed clock_setres() function originated from UNIX
systems.

---
  winsup/doc/posix.xml | 11 ++-
  1 file changed, 10 insertions(+), 1 deletion(-)


Yeah, this is probably the right thing to do.  I'm jsut waiting
for Brian in terms of the POSIX doc update.  That's why I wait with
the eaccess and acl functions as well.


I'll resubmit some time this week.

--
Take care. Thanks, Brian Inglis  Calgary, Alberta, Canada

La perfection est atteinte   Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter  not when there is no more to add
mais lorsqu'il n'y a plus rien à retrancher  but when there is no more to cut
-- Antoine de Saint-Exupéry