all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Ludovic Courtès" <ludo@gnu.org>
To: Lars-Dominik Braun <ldb@leibniz-psychology.org>
Cc: 41720@debbugs.gnu.org
Subject: [bug#41720] [PATCH] store: Use buffered I/O for all protocol writes
Date: Fri, 05 Jun 2020 23:33:02 +0200	[thread overview]
Message-ID: <875zc5xkoh.fsf@gnu.org> (raw)
In-Reply-To: <20200605091151.GB3225@zpidnp36> (Lars-Dominik Braun's message of "Fri, 5 Jun 2020 11:11:51 +0200")

Hi,

Lars-Dominik Braun <ldb@leibniz-psychology.org> skribis:

> I did some digging to investigate why SSH-based guix operations are currently
> so slow. One of the reasons seems to be that some operations write single words
> to the socket and due to NOWAIT these result in a lot of small packets.

Good catch!

> The attached patch modifies store.scm to buffer all writes, so that won’t happen
> any more. I’m seeing about ~40% speedup (6.194s vs 10.075s for the best out of
> five runs) for `GUIX_DAEMON_SOCKET=ssh://localhost guix environment guix --
> true`, but it also seems to have a negative impact on UNIX domain socket
> communication by ~10% (1.561s vs 1.385s). For the notorious r-learnr package
> it’s still ~20% better (ssh, 16.620/21.418) and only ~3% worse (unix,
> 11.489/11.199). Keep in mind localhost has a much larger MTU and much lower
> latency than usual networks though. It might benefit from having an even bigger
> write buffer (64k vs. currently 8k).

Nice, though the slowdown on Unix-domain sockets is annoying given that
it’s the primary transport.  Are the 10% significant and stable over
multiple runs?

It may be that writing through the buffered port, with the extra
allocations, indirection through the custom port, etc., outweighs the
gains.

OTOH all the other RPCs are buffered, so it makes sense to just do the
same.

(It may be wiser to make the ‘operation’ macro smarter and emit code
that directly allocates a bytevector of the right size and sends it.
Future work!)

> From eb38dc246e5dd33f8a48a99aded8b8dc0c378376 Mon Sep 17 00:00:00 2001
> From: Lars-Dominik Braun <ldb@leibniz-psychology.org>
> Date: Fri, 5 Jun 2020 10:38:32 +0200
> Subject: [PATCH] store: Use buffered I/O for all protocol writes
>
> * guix/store.scm (run-gc) Use buffered output port.
> (export-path) Same.
> (add-file-tree-to-store) Same.
> (set-build-options): Same. Add explicit flush.

Look:

--8<---------------cut here---------------start------------->8---
$ GUIX_PROFILING=rpc guix environment guix -- true
Remote procedure call summary: 1927 RPCs
  built-in-builders              ...     1
  build-things                   ...     1
  query-substitutable-path-infos ...     1
  valid-path?                    ...     2
  add-to-store/tree              ...    19
  query-references               ...   108
  add-to-store                   ...   133
  add-text-to-store              ...  1662
--8<---------------cut here---------------end--------------->8---

So probably the gain you’re seeing comes from ‘add-file-tree-to-store’.

Otherwise the patch LGTM as long as it doesn’t introduce any test suite
regressions.

Thanks for investigating!

Ludo’.




  reply	other threads:[~2020-06-05 21:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-05  9:11 [bug#41720] [PATCH] store: Use buffered I/O for all protocol writes Lars-Dominik Braun
2020-06-05 21:33 ` Ludovic Courtès [this message]
2020-06-08  6:42   ` Lars-Dominik Braun
2020-06-09  7:49     ` bug#41720: " Ludovic Courtès
2020-06-09  8:21       ` [bug#41720] " Lars-Dominik Braun

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=875zc5xkoh.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=41720@debbugs.gnu.org \
    --cc=ldb@leibniz-psychology.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 external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.