From patchwork Tue Feb 6 09:36:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adriel Dumas--Jondeau X-Patchwork-Id: 59863 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id D3CF627BBEC; Tue, 6 Feb 2024 09:37:20 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 3E43F27BBEA for ; Tue, 6 Feb 2024 09:37:15 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rXHst-0008Rw-84; Tue, 06 Feb 2024 04:36:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rXHsn-0008Nq-Qj for guix-patches@gnu.org; Tue, 06 Feb 2024 04:36:50 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rXHsn-0007HD-4t; Tue, 06 Feb 2024 04:36:49 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rXHsz-0006zP-NF; Tue, 06 Feb 2024 04:37:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#68876] [PATCH] [PATCH maintenance] doc: guix-days-2024: Add notes from the profiling discussion. References: <20240201171315.16778-1-jonathan.brielmaier@web.de> In-Reply-To: <20240201171315.16778-1-jonathan.brielmaier@web.de> Resent-From: Adriel Dumas--Jondeau Original-Sender: "Debbugs-submit" Resent-CC: jonathan.brielmaier@web.de, ludo@gnu.org, guix-patches@gnu.org Resent-Date: Tue, 06 Feb 2024 09:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68876 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 68876@debbugs.gnu.org Cc: Jonathan Brielmaier , Ludovic =?utf-8?q?Cour?= =?utf-8?q?t=C3=A8s?= X-Debbugs-Original-Xcc: Jonathan Brielmaier , Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 68876-submit@debbugs.gnu.org id=B68876.170721220726844 (code B ref 68876); Tue, 06 Feb 2024 09:37:01 +0000 Received: (at 68876) by debbugs.gnu.org; 6 Feb 2024 09:36:47 +0000 Received: from localhost ([127.0.0.1]:53221 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rXHsl-0006ys-6Q for submit@debbugs.gnu.org; Tue, 06 Feb 2024 04:36:47 -0500 Received: from layka.disroot.org ([178.21.23.139]:47376) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rXHsf-0006yg-3j for 68876@debbugs.gnu.org; Tue, 06 Feb 2024 04:36:46 -0500 Received: from localhost (localhost [127.0.0.1]) by disroot.org (Postfix) with ESMTP id 667F440C45 for <68876@debbugs.gnu.org>; Tue, 6 Feb 2024 10:36:26 +0100 (CET) X-Virus-Scanned: SPAM Filter at disroot.org Received: from layka.disroot.org ([127.0.0.1]) by localhost (disroot.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hqQwMNTMcSKL for <68876@debbugs.gnu.org>; Tue, 6 Feb 2024 10:36:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=disroot.org; s=mail; t=1707212185; bh=Al64pd5btgmoY2Y1NVB2qFiF5pQv6akxbMsm05r2xD4=; h=From:To:Subject:Date; b=E5CcDWq1LlaXahbfm+BwiItUQy9E8Xwuf4MB+gKFhjoCzDJdVpIXNBERfc912lDj8 5RyW6idhHOQKxCeul2G3pgJTeg+txAj1A7UpPQy7moBG4qoT36HIiAlVu65gwTNp9R 7E6dGlbGJKz4cVyg9lKWyuvcrQPxXrKOMFvQo2uI2aERZUCQR9hlXnDcjJ002cuoeO DnAelRKfz9Ku3Wpmwdbf6ON/EOh8X2RzNMTscOIklBtUvGvcrds3lJFii0dzfjXpX2 0RLg/DQdQEXk1n597pfCRz3mZ7lNhcxvo2dIKLq0s9r46WBg1p29JrPOyBJrvsClj/ zUo3mj+rWjTlQ== Date: Tue, 6 Feb 2024 10:36:11 +0100 Message-ID: <20e0abfb8d6e7c4584b2c7dea292669f1a63a29f.1707211674.git.leirda@disroot.org> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Adriel Dumas--Jondeau X-ACL-Warn: , Adriel Dumas--Jondeau via Guix-patches X-Patchwork-Original-From: Adriel Dumas--Jondeau via Guix-patches via From: Adriel Dumas--Jondeau Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches Change-Id: I57abb36cbab43010f43270e626087cb2cb211c14 --- doc/guix-days-2024/profiling.md | 81 +++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 doc/guix-days-2024/profiling.md Hi o/ Here are the notes (unmodified, but we now know why ~,trace~ doesn't behave the same in a ~guix repl~ than in ~guile~, as it is not the same VM used in both) we've taken during the profiling session. base-commit: a4464bd0975c811f18af98f69032b29bddda5b81 prerequisite-patch-id: cefc174692b72660bf5ed4c03442f33dbaf6e784 prerequisite-patch-id: 6b1015959d122056b883e766306b0ff8ba30bde9 prerequisite-patch-id: a3116f7908bc9fdb237e4cde52260856b083596d prerequisite-patch-id: db1d3d945579284d401944b18fcbc506a000714f prerequisite-patch-id: 84bff5e4689979f565315edf96250ccc367f8fb8 prerequisite-patch-id: bd69d4115bc86b7d2739e9890625788f1fa5a006 prerequisite-patch-id: 0834ca6f4e7f1ed91b5dcb679096a953a6e36273 prerequisite-patch-id: 9812bf7906d21768559f10f97d8363d2a18fc7e9 prerequisite-patch-id: 68e70365da7db55420105f7cb12c9fffb80d2415 diff --git a/doc/guix-days-2024/profiling.md b/doc/guix-days-2024/profiling.md new file mode 100644 index 0000000000..f484a2ff3c --- /dev/null +++ b/doc/guix-days-2024/profiling.md @@ -0,0 +1,81 @@ +# What is profiling? + +- Have an idea of the execution time of part of code +- Have some kind of flame graph +- What feels slow (not necessarily what is slow) +- Where's RAM most used? + +# What should be profiled? + +- guix authenticate +- guix system/home +- guix pull +- not the compilation itself +- Guix system start time (like ~systemd-analyse~) +- Time of deployments + +# Why? + +- To be able to use Guix on low-end/older devices +- Building a package is long (because of compilation) +- Pulling is slow (because of network) +- Computing Guix derivations (guix system init/reconfigure) +- Authenticating guix commits (especially with many/big commits) + +- It's compelling (for HPC people for instance) + +- To know where there's progress to be made +- ~make~ in the Guix repo is slow so testing is not as immediate as it could be +- As small/fast finale binary as possible +- To get a feel of what specs are needed to do actual stuff + +# How? + +- Guile has ~trace~ / ~profile~ procedure that you could use on Guix procs + - How to make a flame graph from this data or any other format? +- Retrieving some metrics on demand from build systems (via ~guix build~) + - to get logs RAM/space/temporal usage during compilation +- Profiling daemons resources usage from shepherd (exposing those profiling options to users) +- Making shepherd services to profile ~guix shell --container~ + +# Starting point + +``` +$ guix repl +(guix-user)> ,use (guix scripts build) +(guix-user)> ,profile (guix-build "hello") +% cumulative self +time seconds seconds procedure + 24.00 0.16 0.16 put-string + 16.00 0.11 0.11 write + 12.00 0.11 0.08 append + 12.00 0.08 0.08 get-bytevector-n + 4.00 0.05 0.03 guix/gexp.scm:809:0:gexp-attribute + 4.00 0.03 0.03 string->utf8 + 4.00 0.03 0.03 guix/packages.scm:1969:0:package->derivation + 4.00 0.03 0.03 regexp-exec + 4.00 0.03 0.03 cons + 4.00 0.03 0.03 guix/store.scm:1426:4 + 4.00 0.03 0.03 apply-smob/1 + 4.00 0.03 0.03 sort +(guix-user)> ,trace (guix-build "hello") ; doesn't output any trace for some reason +/gnu/store/6fbh8phmp3izay6c0dpggpxhcjn4xlm5-hello-2.12.1 +(guix-user)> ^D +$ guile +(guile-user)> ,use (guix scripts build) +(guile-user)> ,trace (guix-build "hello") ; however it does work +trace: | (guix-build "hello") +trace: | | (_ (guix scripts) #:ensure #f) +trace: | | (_ #) +trace: | | | (lock-mutex #) +... +trace: | | | | | | (fileno #) +trace: | | | | | | 1 +trace: | | | | | | (bytevector->pointer@system/foreign #vu8(0 0 0 0 0 0 0 0)) +trace: | | | | | | (bytevector->pointer #vu8(0 0 0 0 0 0 0 0)) +trace: | | | | | | # +``` + +```sh +$ guix build --verbosity= --debug= +```