Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 16 Sep 2022 11:04:53 +0200
From:      Daniel Engberg <diizzy@FreeBSD.org>
To:        Nuno Teixeira <eduardo@freebsd.org>
Cc:        Mark Millard <marklmi@yahoo.com>, FreeBSD Mailing List <freebsd-ports@freebsd.org>
Subject:   Re: Default optimization of rust ports
Message-ID:  <c3f56972f6651bf20c22ce56b54973c4@FreeBSD.org>
In-Reply-To: <CAFDf7U%2BDjTqi8JwqPBnaL0AuwB8SzHptVghT7mHgibZsqSgKtg@mail.gmail.com>
References:  <64978B1B-B01A-4145-996D-27F0A87E994E.ref@yahoo.com> <64978B1B-B01A-4145-996D-27F0A87E994E@yahoo.com> <CAFDf7U%2BDjTqi8JwqPBnaL0AuwB8SzHptVghT7mHgibZsqSgKtg@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
--=_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 <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=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

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; charset=
=3DUTF-8" /></head><body style=3D'font-size: 10pt; font-family: Verdana,Gen=
eva,sans-serif'>
<p id=3D"reply-intro">On 2022-09-13 11:54, Nuno Teixeira wrote:</p>
<blockquote type=3D"cite" style=3D"padding: 0 0.4em; border-left: #1010ff 2=
px solid; margin: 0">
<div id=3D"replybody1">
<div dir=3D"ltr">
<div>Hi,</div>
<div>&nbsp;</div>
<div>I think this issue is related to what happened in terms of optimizatio=
ns in go <span class=3D"v1element-details">1.18.3_1:</span></div>
---<br />Add amd64 microarchitecture level knobs for the Go compiler. Note =
that<br />this will affect only the compiler itself, port users will still =
need to<br />set GOAMD64 in the environment to adjust the microarchitecture=
 of the<br />compiled code<br />---<span class=3D"v1element-details"></span>
<div>I've found this optimizations interesting, e.g.:</div>
<div>---</div>
<div>The current high level steps to reduce binary size are:</div>
<div>
<ol>
<li>Use Rust 1.32.0 or newer (which doesn't include <code>jemalloc</code> b=
y default)</li>
<li>Add the following to <a href=3D"https://doc.rust-lang.org/cargo/referen=
ce/manifest.html" target=3D"_blank" rel=3D"noopener noreferrer"><code>Cargo=
=2Etoml</code></a>:</li>
</ol>
[profile.release]<br />opt-level =3D 'z' &nbsp; &nbsp; # Optimize for size.=
<br />lto =3D true &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# Enable Link Time Opt=
imization<br />codegen-units =3D 1 &nbsp; # Reduce number of codegen units =
to increase optimizations.<br />panic =3D 'abort' &nbsp; &nbsp; # Abort on =
panic<br />strip =3D true &nbsp; &nbsp; &nbsp; &nbsp;# Strip symbols from b=
inary*<br /><br />*strip =3D true requires Rust 1.59+. On older Rust versio=
ns, run strip manually on the resulting binary.</div>
<div>---</div>
<div>&nbsp;</div>
<div>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]?</div>
<div>&nbsp;</div>
<div>Cheers,</div>
</div>
<br />
<div class=3D"v1gmail_quote">
<div class=3D"v1gmail_attr" dir=3D"ltr">Mark Millard &lt;<a href=3D"mailto:=
marklmi@yahoo.com" rel=3D"noreferrer">marklmi@yahoo.com</a>&gt; escreveu no=
 dia s&aacute;bado, 10/09/2022 &agrave;(s) 12:53:</div>
<blockquote class=3D"v1gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; bor=
der-left: 1px solid #cccccc; padding-left: 1ex;">Daniel Engberg &lt;diizzy_=
at_FreeBSD.org&gt; wrote on<br />Date: Sat, 10 Sep 2022 09:45:21 UTC :<br /=
><br />&gt; Since there is work and general interest regarding optimization=
 would it <br />&gt; make sense to make LTO and possibly CODEGEN_UNITS=3D1 =
opt-out while we <br />&gt; still have a fairly manageable amount of ports =
using Rust?<br /><br /><br />Just making sure I understand the wording:<br =
/><br />So, in part, you are requesting that the FreeBSD build servers buil=
d<br />using LTO and CODEGEN_UNITS=3D1? (Those build servers always use the=
<br />defaults as I understand. Thus, the defaults are set to what is<br />=
desired for use on the build servers, if I understand right. Other<br />con=
texts that happen to want something different override some<br />default(s)=
: opt out of the defaults.)<br /><br />=3D=3D=3D<br />Mark Millard<br />mar=
klmi at <a href=3D"http://yahoo.com" target=3D"_blank" rel=3D"noopener nore=
ferrer">yahoo.com</a><br /><br /><br /></blockquote>
</div>
<br clear=3D"all" /><br />-- <br />
<div class=3D"v1gmail_signature" dir=3D"ltr">
<div dir=3D"ltr"><span style=3D"color: #666666;">Nuno Teixeira<br />FreeBSD=
 Committer (ports)</span></div>
<div dir=3D"ltr">&nbsp;</div>
<div dir=3D"ltr">Hi,</div>
<div dir=3D"ltr">&nbsp;</div>
<div dir=3D"ltr">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.</=
div>
<div dir=3D"ltr">These are ENV variables so one wouldn't need to touch indu=
vidual ports.</div>
<div dir=3D"ltr">&nbsp;</div>
<div dir=3D"ltr">Best regards,</div>
<div dir=3D"ltr">Daniel</div>
</div>
</div>
</blockquote>
<p><br /></p>

</body></html>

--=_12bf01284aa403734d7443b3142a9865--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?c3f56972f6651bf20c22ce56b54973c4>