Message ID | f0435844501301f1850deffe64d3ac254007f4c3.1687247150.git.efraim@flashner.co.il |
---|---|
State | New |
Headers |
Return-Path: <guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org> X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id A8CDC27BBE9; Tue, 20 Jun 2023 08:52:48 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS autolearn=unavailable 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 24B9227BBE2 for <patchwork@mira.cbaines.net>; Tue, 20 Jun 2023 08:52:48 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from <guix-patches-bounces@gnu.org>) id 1qBW9o-0003nR-KK; Tue, 20 Jun 2023 03:52:08 -0400 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 <Debian-debbugs@debbugs.gnu.org>) id 1qBW9n-0003ms-2U for guix-patches@gnu.org; Tue, 20 Jun 2023 03:52:07 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1qBW9m-0006OA-Oc; Tue, 20 Jun 2023 03:52:06 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1qBW9j-00056Z-V7; Tue, 20 Jun 2023 03:52:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#64188] [PATCH 6/8] transformations: Allow tuning go packages. Resent-From: Efraim Flashner <efraim@flashner.co.il> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org> Resent-CC: mail@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Tue, 20 Jun 2023 07:52:03 +0000 Resent-Message-ID: <handler.64188.B64188.168724748819521@debbugs.gnu.org> Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64188 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 64188@debbugs.gnu.org Cc: Efraim Flashner <efraim@flashner.co.il>, Christopher Baines <mail@cbaines.net>, Josselin Poiret <dev@jpoiret.xyz>, Ludovic =?utf-8?q?Court=C3=A8s?= <ludo@gnu.org>, Mathieu Othacehe <othacehe@gnu.org>, Ricardo Wurmus <rekado@elephly.net>, Simon Tournier <zimon.toutoune@gmail.com>, Tobias Geerinckx-Rice <me@tobias.gr> X-Debbugs-Original-Xcc: Christopher Baines <mail@cbaines.net>, Josselin Poiret <dev@jpoiret.xyz>, Ludovic =?utf-8?q?Court=C3=A8s?= <ludo@gnu.org>, Mathieu Othacehe <othacehe@gnu.org>, Ricardo Wurmus <rekado@elephly.net>, Simon Tournier <zimon.toutoune@gmail.com>, Tobias Geerinckx-Rice <me@tobias.gr> Received: via spool by 64188-submit@debbugs.gnu.org id=B64188.168724748819521 (code B ref 64188); Tue, 20 Jun 2023 07:52:03 +0000 Received: (at 64188) by debbugs.gnu.org; 20 Jun 2023 07:51:28 +0000 Received: from localhost ([127.0.0.1]:57963 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>) id 1qBW99-00054m-QT for submit@debbugs.gnu.org; Tue, 20 Jun 2023 03:51:28 -0400 Received: from mail-lf1-f54.google.com ([209.85.167.54]:56569) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <efraim.flashner@gmail.com>) id 1qBW94-00053m-Nk for 64188@debbugs.gnu.org; Tue, 20 Jun 2023 03:51:23 -0400 Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-4f866a3d8e4so3734167e87.0 for <64188@debbugs.gnu.org>; Tue, 20 Jun 2023 00:51:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687247476; x=1689839476; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=s+4t5DdUHTaWV4XSXAE8le0FxTs+pztfyGUuJdYMBZg=; b=L/z/P9IhBdAo/NNNY2RPrbUoOuZwZdjDpM3j6ilDXWRwxodVVJqge5mPdeN3dFpqg4 3MmM8cnYYh73VjhLqHYatrw+ysCthf4+kHo/VNPA8+N4l8DpUWmh1wslFwLgqRyw3jJi 4ZLik51RpzzbaqD0N5AinIjSmHtVDLdQLgf6Wy9FKY0Ct/4x69tWCNwa4B3b7LXETR58 7I94arlCKFvZnFuWdE1zLMwGBehh/AQm4MoTaVqadoqiLQ2coHIov/+6Oy8s4HrQZl1Q FaRakOlVYgVOxzcM5QJoEn58Zf0ecrPzXk1YNW5o4YJt6Mec1Mj+ZVqarOUXzwibookl lOpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687247476; x=1689839476; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=s+4t5DdUHTaWV4XSXAE8le0FxTs+pztfyGUuJdYMBZg=; b=Bhmf8wQ891FDSmnmum9uSWmcVGYfbvRXiD840u4lo52Un4rM5DW0EtMrP4i3b0pYo+ GwOfjgD+v/tPb0W3mJ++mF+oJOHpScbKZacb0m+crhG5W1KoC8bb8xUbY1slOWLXnPju jttgBQrEf48oXx53FtaTAK/t3CysX1v+1IFi9m1HY2wzdQtYcc5UJM3ntPbDV25n2Yje 84jASI3Nggc4p9tVG9FVWld7q6ygDqqd1yPFqkMhZLafpWQmiD2K/mKTBWV2WWg0TME9 zTTwOi7UoQ2l/w1jqDNqzuhgrJC7fhkdzJ2kxchAcn3mwClbRCmhWJJN/bHugVOccn3n XdyA== X-Gm-Message-State: AC+VfDzfHMQYckpGa9XwhswLaBmYaQ+dEg5Fndsqf6uEmA7gebKsGIpS SN52oGDtrofrBuvbBpih2iTaG//TR0qrJbcb X-Google-Smtp-Source: ACHHUZ7qNWXgwzdo2afU1oj63AQWDR7tU4vaz8ZfDMob3EiGJgTj9pXYztbrxqPyQb6dWvrXi2kKcQ== X-Received: by 2002:a19:4409:0:b0:4f8:7556:23e6 with SMTP id r9-20020a194409000000b004f8755623e6mr2029931lfa.54.1687247476231; Tue, 20 Jun 2023 00:51:16 -0700 (PDT) Received: from localhost ([188.120.129.124]) by smtp.gmail.com with ESMTPSA id x11-20020adff0cb000000b003112d12a1ecsm1312246wro.98.2023.06.20.00.51.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 00:51:15 -0700 (PDT) From: Efraim Flashner <efraim@flashner.co.il> Date: Tue, 20 Jun 2023 10:51:07 +0300 Message-Id: <f0435844501301f1850deffe64d3ac254007f4c3.1687247150.git.efraim@flashner.co.il> X-Mailer: git-send-email 2.40.1 In-Reply-To: <cover.1687247150.git.efraim@flashner.co.il> References: <cover.1687247150.git.efraim@flashner.co.il> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: <guix-patches.gnu.org> List-Unsubscribe: <https://lists.gnu.org/mailman/options/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=unsubscribe> List-Archive: <https://lists.gnu.org/archive/html/guix-patches> List-Post: <mailto:guix-patches@gnu.org> List-Help: <mailto:guix-patches-request@gnu.org?subject=help> List-Subscribe: <https://lists.gnu.org/mailman/listinfo/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=subscribe> 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 |
Series |
More package tuning
|
|
Commit Message
Efraim Flashner
June 20, 2023, 7:51 a.m. UTC
* guix/transformations.scm (tuned-package)[build-system]: Don't replace the build-system if inheriting from the go-build-system. [arguments]: If using the go-build-system add a phase to set the micro-architecture for Go. --- guix/transformations.scm | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-)
Comments
Efraim Flashner <efraim@flashner.co.il> skribis: > * guix/transformations.scm (tuned-package)[build-system]: Don't replace > the build-system if inheriting from the go-build-system. > [arguments]: If using the go-build-system add a phase to set the > micro-architecture for Go. [...] > @@ -570,14 +571,42 @@ (define (tuned-package p micro-architecture) > (package > (inherit p) > (build-system > - (build-system-with-tuning-compiler (package-build-system p) > - micro-architecture)) > + ;; The go compiler doesn't need to be wrapped. > + ;; XXX: This is where we check for supported micro-architectures. > + (if (eq? (build-system-name (package-build-system p)) > + 'go) > + (package-build-system p) > + (build-system-with-tuning-compiler (package-build-system p) > + micro-architecture))) > (arguments > ;; The machine building this package may or may not be able to run code > ;; for MICRO-ARCHITECTURE. Because of that, skip tests; they are run for > ;; the "baseline" variant anyway. > (substitute-keyword-arguments (package-arguments p) > - ((#:tests? _ #f) #f))) > + ((#:tests? _ #f) #f) > + ;; We add the tuning parameter after the default GO flags are set. > + ((#:phases phases '%standard-phases) > + (if (eq? (build-system-name (package-build-system p)) > + 'go) > + #~(modify-phases #$phases > + (add-after 'setup-go-environment 'set-microarchitecture Can we use the same approach as before with ‘build-system-with-tuning-compiler’? That seems more robust to me and it’d be more consistent. Ludo’.
On Sun, Jun 25, 2023 at 10:52:14PM +0200, Ludovic Courtès wrote: > Efraim Flashner <efraim@flashner.co.il> skribis: > > > * guix/transformations.scm (tuned-package)[build-system]: Don't replace > > the build-system if inheriting from the go-build-system. > > [arguments]: If using the go-build-system add a phase to set the > > micro-architecture for Go. > > [...] > > > @@ -570,14 +571,42 @@ (define (tuned-package p micro-architecture) > > (package > > (inherit p) > > (build-system > > - (build-system-with-tuning-compiler (package-build-system p) > > - micro-architecture)) > > + ;; The go compiler doesn't need to be wrapped. > > + ;; XXX: This is where we check for supported micro-architectures. > > + (if (eq? (build-system-name (package-build-system p)) > > + 'go) > > + (package-build-system p) > > + (build-system-with-tuning-compiler (package-build-system p) > > + micro-architecture))) > > (arguments > > ;; The machine building this package may or may not be able to run code > > ;; for MICRO-ARCHITECTURE. Because of that, skip tests; they are run for > > ;; the "baseline" variant anyway. > > (substitute-keyword-arguments (package-arguments p) > > - ((#:tests? _ #f) #f))) > > + ((#:tests? _ #f) #f) > > + ;; We add the tuning parameter after the default GO flags are set. > > + ((#:phases phases '%standard-phases) > > + (if (eq? (build-system-name (package-build-system p)) > > + 'go) > > + #~(modify-phases #$phases > > + (add-after 'setup-go-environment 'set-microarchitecture > > Can we use the same approach as before with > ‘build-system-with-tuning-compiler’? That seems more robust to me and > it’d be more consistent. I'll look to see how to move this into build-system-with-tuning-compiler. I think I previously got hung-up on the tuning-compiler function which wouldn't work for go. At first glance it looks like I could just lift-and-shift the extra phase over. I'll just have to make sure that either it's only for the go-build-system or occurs sometime after the setup-go-environment phase but before/after a phase which exists in all build systems. Then it's the toss-up between leaving it as-is and only occurring with the go-build-system or also occurring on any tuned package which also has go code.
Hi Efraim, Thanks for pushing this patch series past the finish line! Efraim Flashner <efraim@flashner.co.il> skribis: > I'll look to see how to move this into > build-system-with-tuning-compiler. I think I previously got hung-up on > the tuning-compiler function which wouldn't work for go. At first glance > it looks like I could just lift-and-shift the extra phase over. I'll > just have to make sure that either it's only for the go-build-system or > occurs sometime after the setup-go-environment phase but before/after a > phase which exists in all build systems. Then it's the toss-up between > leaving it as-is and only occurring with the go-build-system or also > occurring on any tuned package which also has go code. It looks like we’re now adding the ‘set-microarchitecture’ phase unconditionally, not just for go. For example: --8<---------------cut here---------------start------------->8--- $ ./pre-inst-env guix build --tune eigen-benchmarks --log-file guix build: tuning eigen-benchmarks@3.4.0 for CPU skylake https://ci.guix.gnu.org/log/djwka1jhzhk08yb23as83yk5hysn0pky-eigen-benchmarks-3.4.0 $ wget -qO- https://ci.guix.gnu.org/log/djwka1jhzhk08yb23as83yk5hysn0pky-eigen-benchmarks-3.4.0 |gunzip -c| grep -C3 set-micro phase `reset-gzip-timestamps' succeeded after 0.0 seconds starting phase `compress-documentation' phase `compress-documentation' succeeded after 0.0 seconds starting phase `set-microarchitecture' Setting GOAMD to "v3". phase `set-microarchitecture' succeeded after 0.0 seconds @ build-succeeded /gnu/store/pdz0g9q2yd9i1jkbhk2rnbfa88ngvffw-eigen-benchmarks-3.4.0.drv - --8<---------------cut here---------------end--------------->8--- What I had in mind was to have a procedure similar to ‘tuning-compiler’ that would return a wrapper around the “go” binary that would set ‘GOAMD’ (or similar). That way the change would be well isolated. Could you look into providing a patch for that? Thanks in advance! Ludo’.
On Thu, Jul 13, 2023 at 05:27:21PM +0200, Ludovic Courtès wrote: > Hi Efraim, > > Thanks for pushing this patch series past the finish line! > > Efraim Flashner <efraim@flashner.co.il> skribis: > > > I'll look to see how to move this into > > build-system-with-tuning-compiler. I think I previously got hung-up on > > the tuning-compiler function which wouldn't work for go. At first glance > > it looks like I could just lift-and-shift the extra phase over. I'll > > just have to make sure that either it's only for the go-build-system or > > occurs sometime after the setup-go-environment phase but before/after a > > phase which exists in all build systems. Then it's the toss-up between > > leaving it as-is and only occurring with the go-build-system or also > > occurring on any tuned package which also has go code. > > It looks like we’re now adding the ‘set-microarchitecture’ phase > unconditionally, not just for go. For example: > > --8<---------------cut here---------------start------------->8--- > $ ./pre-inst-env guix build --tune eigen-benchmarks --log-file > guix build: tuning eigen-benchmarks@3.4.0 for CPU skylake > https://ci.guix.gnu.org/log/djwka1jhzhk08yb23as83yk5hysn0pky-eigen-benchmarks-3.4.0 > $ wget -qO- https://ci.guix.gnu.org/log/djwka1jhzhk08yb23as83yk5hysn0pky-eigen-benchmarks-3.4.0 |gunzip -c| grep -C3 set-micro > phase `reset-gzip-timestamps' succeeded after 0.0 seconds > starting phase `compress-documentation' > phase `compress-documentation' succeeded after 0.0 seconds > starting phase `set-microarchitecture' > Setting GOAMD to "v3". > phase `set-microarchitecture' succeeded after 0.0 seconds > @ build-succeeded /gnu/store/pdz0g9q2yd9i1jkbhk2rnbfa88ngvffw-eigen-benchmarks-3.4.0.drv - > --8<---------------cut here---------------end--------------->8--- > > What I had in mind was to have a procedure similar to ‘tuning-compiler’ > that would return a wrapper around the “go” binary that would set > ‘GOAMD’ (or similar). That way the change would be well isolated. > > Could you look into providing a patch for that? > > Thanks in advance! > > Ludo’. That's actually really surprising to me. I thought that if you tried to add a phase after a non-existent phase then it just wouldn't be added. I tried just wrapping the call to the 'go' binary itself so that every time 'go' was called it would also set the environment variable setting the optimization level but I was having a hard time working that. While experimenting I did change what I had written to check for the 'setup-go-environment phase, and if it existed to add the optimization at the end of that phase. I have the part with wrapping the go binary as a WIP, and when it's ready I'll post both parts so we can choose which one seems better. I like the idea of go being wrapped, it makes it easier to just add in the optimizations whenever go is added to a package. On the other hand I like the extra phase, since it's already done :)
Hi, Efraim Flashner <efraim@flashner.co.il> skribis: > On Thu, Jul 13, 2023 at 05:27:21PM +0200, Ludovic Courtès wrote: [...] >> It looks like we’re now adding the ‘set-microarchitecture’ phase >> unconditionally, not just for go. For example: >> >> --8<---------------cut here---------------start------------->8--- >> $ ./pre-inst-env guix build --tune eigen-benchmarks --log-file >> guix build: tuning eigen-benchmarks@3.4.0 for CPU skylake >> https://ci.guix.gnu.org/log/djwka1jhzhk08yb23as83yk5hysn0pky-eigen-benchmarks-3.4.0 >> $ wget -qO- https://ci.guix.gnu.org/log/djwka1jhzhk08yb23as83yk5hysn0pky-eigen-benchmarks-3.4.0 |gunzip -c| grep -C3 set-micro >> phase `reset-gzip-timestamps' succeeded after 0.0 seconds >> starting phase `compress-documentation' >> phase `compress-documentation' succeeded after 0.0 seconds >> starting phase `set-microarchitecture' >> Setting GOAMD to "v3". >> phase `set-microarchitecture' succeeded after 0.0 seconds >> @ build-succeeded /gnu/store/pdz0g9q2yd9i1jkbhk2rnbfa88ngvffw-eigen-benchmarks-3.4.0.drv - >> --8<---------------cut here---------------end--------------->8--- >> >> What I had in mind was to have a procedure similar to ‘tuning-compiler’ >> that would return a wrapper around the “go” binary that would set >> ‘GOAMD’ (or similar). That way the change would be well isolated. >> >> Could you look into providing a patch for that? >> >> Thanks in advance! >> >> Ludo’. > > That's actually really surprising to me. I thought that if you tried to > add a phase after a non-existent phase then it just wouldn't be added. Actually I thought so too. :-) But anyway, the point is that we’re modifying phases unconditionally (whether or not this has an effect), and it would be nicer to avoid it IMO. > I tried just wrapping the call to the 'go' binary itself so that every > time 'go' was called it would also set the environment variable setting > the optimization level but I was having a hard time working that. While > experimenting I did change what I had written to check for the > 'setup-go-environment phase, and if it existed to add the optimization > at the end of that phase. > > I have the part with wrapping the go binary as a WIP, and when it's > ready I'll post both parts so we can choose which one seems better. I > like the idea of go being wrapped, it makes it easier to just add in the > optimizations whenever go is added to a package. On the other hand I > like the extra phase, since it's already done :) Not a valid argument! :-) We can discuss the implementation on IRC if you want. It might be that we can slightly generalize ‘tuning-compiler’ so that it works for go (perhaps there’s an option like ‘-march’ that we could use instead of setting ‘GOAMD’?). Thanks in advance! Ludo’.
diff --git a/guix/transformations.scm b/guix/transformations.scm index a289f81219..47eb4b0515 100644 --- a/guix/transformations.scm +++ b/guix/transformations.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2016-2023 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2021 Marius Bakke <marius@gnu.org> ;;; Copyright © 2023 Sarthak Shah <shahsarthakw@gmail.com> +;;; Copyright © 2023 Efraim Flashner <efraim@flashner.co.il> ;;; ;;; This file is part of GNU Guix. ;;; @@ -570,14 +571,42 @@ (define (tuned-package p micro-architecture) (package (inherit p) (build-system - (build-system-with-tuning-compiler (package-build-system p) - micro-architecture)) + ;; The go compiler doesn't need to be wrapped. + ;; XXX: This is where we check for supported micro-architectures. + (if (eq? (build-system-name (package-build-system p)) + 'go) + (package-build-system p) + (build-system-with-tuning-compiler (package-build-system p) + micro-architecture))) (arguments ;; The machine building this package may or may not be able to run code ;; for MICRO-ARCHITECTURE. Because of that, skip tests; they are run for ;; the "baseline" variant anyway. (substitute-keyword-arguments (package-arguments p) - ((#:tests? _ #f) #f))) + ((#:tests? _ #f) #f) + ;; We add the tuning parameter after the default GO flags are set. + ((#:phases phases '%standard-phases) + (if (eq? (build-system-name (package-build-system p)) + 'go) + #~(modify-phases #$phases + (add-after 'setup-go-environment 'set-microarchitecture + (lambda _ + (let ((microarch #$micro-architecture)) + (cond + ((string-prefix? "arm" microarch) + (setenv "GOARM" (string-take-right microarch 1)) + (format #t "Setting GOARM to ~s." + (getenv "GOARM"))) + ((string-prefix? "powerpc" microarch) + (setenv "GOPPC64" microarch) + (format #t "Setting GOPPC64 to ~s." + (getenv "GOPPC64"))) + ((string-prefix? "x86_64" microarch) + (setenv "GOAMD" (string-take-right microarch 2)) + (format #t "Setting GOAMD to ~s.\n" + (getenv "GOAMD"))) + (else #t)))))) + phases)))) (properties `((cpu-tuning . ,micro-architecture)