From nobody Fri Sep 16 09:04:53 2022 X-Original-To: freebsd-ports@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MTSnk247pz4c4dg for ; Fri, 16 Sep 2022 09:04:58 +0000 (UTC) (envelope-from diizzy@FreeBSD.org) Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4MTSnh65t8z3whD; Fri, 16 Sep 2022 09:04:56 +0000 (UTC) (envelope-from diizzy@FreeBSD.org) Received: (Authenticated sender: daniel.engberg@pyret.net) by mail.gandi.net (Postfix) with ESMTPA id 3AD97FF809; Fri, 16 Sep 2022 09:04:53 +0000 (UTC) List-Id: Porting software to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-ports List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-ports@freebsd.org X-BeenThere: freebsd-ports@freebsd.org MIME-Version: 1.0 Date: Fri, 16 Sep 2022 11:04:53 +0200 From: Daniel Engberg To: Nuno Teixeira Cc: Mark Millard , FreeBSD Mailing List Subject: Re: Default optimization of rust ports In-Reply-To: References: <64978B1B-B01A-4145-996D-27F0A87E994E.ref@yahoo.com> <64978B1B-B01A-4145-996D-27F0A87E994E@yahoo.com> Message-ID: X-Sender: diizzy@FreeBSD.org Content-Type: multipart/alternative; boundary="=_12bf01284aa403734d7443b3142a9865" X-Rspamd-Queue-Id: 4MTSnh65t8z3whD X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=softfail (mx1.freebsd.org: 217.70.183.199 is neither permitted nor denied by domain of diizzy@FreeBSD.org) smtp.mailfrom=diizzy@FreeBSD.org X-Spamd-Result: default: False [-2.12 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; URI_COUNT_ODD(1.00)[5]; NEURAL_HAM_SHORT(-1.00)[-0.999]; NEURAL_HAM_MEDIUM(-0.92)[-0.920]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; RCVD_IN_DNSWL_LOW(-0.10)[217.70.183.199:from]; MIME_TRACE(0.00)[0:+,1:+,2:~]; RWL_MAILSPIKE_POSSIBLE(0.00)[217.70.183.199:from]; FREEMAIL_CC(0.00)[yahoo.com,freebsd.org]; R_DKIM_NA(0.00)[]; MLMMJ_DEST(0.00)[freebsd-ports@freebsd.org]; ASN(0.00)[asn:29169, ipnet:217.70.176.0/20, country:FR]; FROM_EQ_ENVFROM(0.00)[]; TO_DN_ALL(0.00)[]; ARC_NA(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; FREEFALL_USER(0.00)[diizzy]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; DMARC_NA(0.00)[freebsd.org]; RCVD_TLS_LAST(0.00)[]; R_SPF_SOFTFAIL(0.00)[~all:c]; RCVD_COUNT_TWO(0.00)[2] X-ThisMailContainsUnwantedMimeParts: N --=_12bf01284aa403734d7443b3142a9865 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8; format=flowed On 2022-09-13 11:54, Nuno Teixeira wrote: > Hi, > > I think this issue is related to what happened in terms of > optimizations in go 1.18.3_1: --- > Add amd64 microarchitecture level knobs for the Go compiler. Note that > this will affect only the compiler itself, port users will still need > to > set GOAMD64 in the environment to adjust the microarchitecture of the > compiled code > --- > I've found this optimizations interesting, e.g.: > --- > The current high level steps to reduce binary size are: > > * Use Rust 1.32.0 or newer (which doesn't include jemalloc by default) > * Add the following to Cargo.toml [2]: > > [profile.release] > opt-level = 'z' # Optimize for size. > lto = true # Enable Link Time Optimization > codegen-units = 1 # Reduce number of codegen units to increase > optimizations. > panic = 'abort' # Abort on panic > strip = true # Strip symbols from binary* > > *strip = true requires Rust 1.59+. On older Rust versions, run strip > manually on the resulting binary. > --- > > I was searching for cargo stripping instead of using STRIP_CMD and I > found this but this means that we have to hack ports Cargo.toml's or > should be upstream to implement a [profile.release]? > > Cheers, > > Mark Millard escreveu no dia sábado, 10/09/2022 > à(s) 12:53: > >> Daniel Engberg wrote on >> Date: Sat, 10 Sep 2022 09:45:21 UTC : >> >>> Since there is work and general interest regarding optimization would >>> it >>> make sense to make LTO and possibly CODEGEN_UNITS=1 opt-out while we >>> still have a fairly manageable amount of ports using Rust? >> >> Just making sure I understand the wording: >> >> So, in part, you are requesting that the FreeBSD build servers build >> using LTO and CODEGEN_UNITS=1? (Those build servers always use the >> defaults as I understand. Thus, the defaults are set to what is >> desired for use on the build servers, if I understand right. Other >> contexts that happen to want something different override some >> default(s): opt out of the defaults.) >> >> === >> Mark Millard >> marklmi at yahoo.com [1] > > -- > > Nuno Teixeira > FreeBSD Committer (ports) > > Hi, > > The suggestion is to make it default for all ports but we can (and > should) make it opt-out as not all outcomes might be favourable. > These are ENV variables so one wouldn't need to touch induvidual ports. > > Best regards, > Daniel Links: ------ [1] http://yahoo.com [2] https://doc.rust-lang.org/cargo/reference/manifest.html --=_12bf01284aa403734d7443b3142a9865 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=UTF-8

On 2022-09-13 11:54, Nuno Teixeira wrote:

Hi,
 
I think this issue is related to what happened in terms of optimizatio= ns in go 1.18.3_1:
---
Add amd64 microarchitecture level knobs for the Go compiler. Note = that
this will affect only the compiler itself, port users will still = need to
set GOAMD64 in the environment to adjust the microarchitecture= of the
compiled code
---
I've found this optimizations interesting, e.g.:
---
The current high level steps to reduce binary size are:
  1. Use Rust 1.32.0 or newer (which doesn't include jemalloc b= y default)
  2. Add the following to Cargo= =2Etoml:
[profile.release]
opt-level =3D 'z'     # Optimize for size.=
lto =3D true          # Enable Link Time Opt= imization
codegen-units =3D 1   # Reduce number of codegen units = to increase optimizations.
panic =3D 'abort'     # Abort on = panic
strip =3D true        # Strip symbols from b= inary*

*strip =3D true requires Rust 1.59+. On older Rust versio= ns, run strip manually on the resulting binary.
---
 
I was searching for cargo stripping instead of using STRIP_CMD and I f= ound this but this means that we have to hack ports Cargo.toml's or should = be upstream to implement a [profile.release]?
 
Cheers,

Mark Millard <marklmi@yahoo.com> escreveu no= dia sábado, 10/09/2022 à(s) 12:53:
Daniel Engberg <diizzy_= at_FreeBSD.org> wrote on
Date: Sat, 10 Sep 2022 09:45:21 UTC :

> Since there is work and general interest regarding optimization= would it
> make sense to make LTO and possibly CODEGEN_UNITS=3D1 = opt-out while we
> still have a fairly manageable amount of ports = using Rust?


Just making sure I understand the wording:

So, in part, you are requesting that the FreeBSD build servers buil= d
using LTO and CODEGEN_UNITS=3D1? (Those build servers always use the=
defaults as I understand. Thus, the defaults are set to what is
= desired for use on the build servers, if I understand right. Other
con= texts that happen to want something different override some
default(s)= : opt out of the defaults.)

=3D=3D=3D
Mark Millard
mar= klmi at yahoo.com




--
Nuno Teixeira
FreeBSD= Committer (ports)
 
Hi,
 
The suggestion is to make it default for all ports but we = can (and should) make it opt-out as not all outcomes might be favourable.
These are ENV variables so one wouldn't need to touch indu= vidual ports.
 
Best regards,
Daniel


--=_12bf01284aa403734d7443b3142a9865--