From: "Ludovic Courtès" <ludo@gnu.org>
To: 48007@debbugs.gnu.org
Subject: bug#48007: computing derivations through inferior takes twice as long
Date: Fri, 18 Feb 2022 12:30:36 +0100 [thread overview]
Message-ID: <87k0dsjtsz.fsf_-_@gnu.org> (raw)
In-Reply-To: <20220127084743.27130-2-ludo@gnu.org> ("Ludovic Courtès"'s message of "Thu, 27 Jan 2022 09:47:41 +0100")
Hi,
Ludovic Courtès <ludo@gnu.org> skribis:
> Previously, each 'inferior-eval-with-store' would lead the inferior to
> connect to the named socket the parent is listening to. With this
> change, the connection is established once for all and reused
> afterwards.
>
> * guix/inferior.scm (<inferior>)[bridge-file-name]: Remove.
> (open-bidirectional-pipe): New procedure.
> (inferior-pipe): Use it instead of 'open-pipe*' and return two values.
> (port->inferior): Adjust call to 'inferior'.
> (open-inferior): Adjust to 'inferior-pipe' changes.
> (close-inferior): Remove 'inferior-bridge-file-name' handling.
> (open-store-bridge!): Switch back to 'call-with-temporary-directory'.
> Define '%bridge-socket' in the inferior, connected to the caller.
> (proxy): Change first argument to be an inferior. Add 'reponse-port'
> and call to 'drain-input'. Pass 'reponse-port' to 'select' and use it
> as a loop termination clause.
> (inferior-eval-with-store): Remove 'socket' and 'connect' calls from the
> inferior code, and use '%bridge-socket' instead.
[...]
> +(define (open-bidirectional-pipe command . args)
> + "Open a bidirectional pipe to COMMAND invoked with ARGS and return it, as a
> +regular file port (socket).
> +
> +This is equivalent to (open-pipe* OPEN_BOTH ...) except that the result is a
> +regular file port that can be passed to 'select' ('open-pipe*' returns a
> +custom binary port)."
> + (match (socketpair AF_UNIX SOCK_STREAM 0)
> + ((parent . child)
> + (match (primitive-fork)
I noticed that there’s at least one case where this is used from a
multi-threaded program, and as we know, fork + threads don’t go well
together:
--8<---------------cut here---------------start------------->8---
$ make as-derivation
[…]
@ build-succeeded /gnu/store/n5jfi8pn1aq1ykmnq75xhr8ba2m7161l-profile.drv -
warning: call to primitive-fork while multiple threads are running;
further behavior unspecified. See "Processes" in the
manual, for more information.
warning: call to primitive-fork while multiple threads are running;
further behavior unspecified. See "Processes" in the
manual, for more information.
warning: call to primitive-fork while multiple threads are running;
further behavior unspecified. See "Processes" in the
manual, for more information.
--8<---------------cut here---------------end--------------->8---
The threads are created in ‘build-aux/cuirass/evaluate.scm’.
In practice it’s OK because the code above calls ‘exec’ right away;
still, it’s annoying.
Ludo’.
next prev parent reply other threads:[~2022-02-18 11:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-24 21:07 bug#48007: computing derivations through inferior takes twice as long Ricardo Wurmus
2022-01-26 20:51 ` Ludovic Courtès
2022-01-26 21:32 ` Ricardo Wurmus
2022-01-27 8:50 ` Ludovic Courtès
2022-01-27 9:56 ` Ricardo Wurmus
2022-01-27 13:33 ` Ludovic Courtès
2022-01-27 8:47 ` bug#48007: [PATCH 1/4] inferior: Create the store proxy listening socket only once Ludovic Courtès
2022-01-27 8:47 ` bug#48007: [PATCH 2/4] inferior: Keep the store bridge connected Ludovic Courtès
2022-02-18 11:30 ` Ludovic Courtès [this message]
2022-01-27 8:47 ` bug#48007: [PATCH 3/4] inferior: Inferior caches store connections Ludovic Courtès
2022-01-27 8:47 ` bug#48007: [PATCH 4/4] inferior: Move initialization bits away from 'inferior-eval-with-store' Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87k0dsjtsz.fsf_-_@gnu.org \
--to=ludo@gnu.org \
--cc=48007@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).