From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id EFp9CVO62l6fWQAA0tVLHw (envelope-from ) for ; Fri, 05 Jun 2020 21:34:11 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id SFU6BVO62l6FHgAAbx9fmQ (envelope-from ) for ; Fri, 05 Jun 2020 21:34:11 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 64F9F940039 for ; Fri, 5 Jun 2020 21:34:10 +0000 (UTC) Received: from localhost ([::1]:59616 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jhJyZ-0006Hr-Bh for larch@yhetil.org; Fri, 05 Jun 2020 17:34:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48140) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jhJyT-0006Hh-Ug for guix-patches@gnu.org; Fri, 05 Jun 2020 17:34:01 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38563) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jhJyT-0007Tu-LV for guix-patches@gnu.org; Fri, 05 Jun 2020 17:34:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jhJyT-0007Sx-I7 for guix-patches@gnu.org; Fri, 05 Jun 2020 17:34:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#41720] [PATCH] store: Use buffered I/O for all protocol writes Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 05 Jun 2020 21:34:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41720 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Lars-Dominik Braun Cc: 41720@debbugs.gnu.org Received: via spool by 41720-submit@debbugs.gnu.org id=B41720.159139279228643 (code B ref 41720); Fri, 05 Jun 2020 21:34:01 +0000 Received: (at 41720) by debbugs.gnu.org; 5 Jun 2020 21:33:12 +0000 Received: from localhost ([127.0.0.1]:50109 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jhJxf-0007Rv-VI for submit@debbugs.gnu.org; Fri, 05 Jun 2020 17:33:12 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35166) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jhJxd-0007Rh-Kn for 41720@debbugs.gnu.org; Fri, 05 Jun 2020 17:33:10 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:48417) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jhJxY-0007OT-7N; Fri, 05 Jun 2020 17:33:04 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=50876 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jhJxX-0005Ax-RB; Fri, 05 Jun 2020 17:33:04 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20200605091151.GB3225@zpidnp36> Date: Fri, 05 Jun 2020 23:33:02 +0200 In-Reply-To: <20200605091151.GB3225@zpidnp36> (Lars-Dominik Braun's message of "Fri, 5 Jun 2020 11:11:51 +0200") Message-ID: <875zc5xkoh.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -3.3 (---) X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: -1.01 X-TUID: TvDhqHmKsQAF Hi, Lars-Dominik Braun skribis: > I did some digging to investigate why SSH-based guix operations are curre= ntly > 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= =E2=80=99t happen > any more. I=E2=80=99m seeing about ~40% speedup (6.194s vs 10.075s for th= e best out of > five runs) for `GUIX_DAEMON_SOCKET=3Dssh://localhost guix environment gui= x -- > 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 pack= age > it=E2=80=99s still ~20% better (ssh, 16.620/21.418) and only ~3% worse (u= nix, > 11.489/11.199). Keep in mind localhost has a much larger MTU and much low= er > 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=E2=80=99s 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 =E2=80=98operation=E2=80=99 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 > 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=3Drpc 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=E2=80=99re seeing comes from =E2=80=98add-file-tre= e-to-store=E2=80=99. Otherwise the patch LGTM as long as it doesn=E2=80=99t introduce any test s= uite regressions. Thanks for investigating! Ludo=E2=80=99.