Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 13 Sep 2022 10:54:47 +0100
From:      Nuno Teixeira <eduardo@freebsd.org>
To:        Mark Millard <marklmi@yahoo.com>
Cc:        "diizzy@freebsd.org" <diizzy@freebsd.org>, FreeBSD Mailing List <freebsd-ports@freebsd.org>
Subject:   Re: Default optimization of rust ports
Message-ID:  <CAFDf7U%2BDjTqi8JwqPBnaL0AuwB8SzHptVghT7mHgibZsqSgKtg@mail.gmail.com>
In-Reply-To: <64978B1B-B01A-4145-996D-27F0A87E994E@yahoo.com>
References:  <64978B1B-B01A-4145-996D-27F0A87E994E.ref@yahoo.com> <64978B1B-B01A-4145-996D-27F0A87E994E@yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
--000000000000576adc05e88c019d
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

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:

   1. Use Rust 1.32.0 or newer (which doesn't include jemalloc by default)
   2. Add the following to Cargo.toml
   <https://doc.rust-lang.org/cargo/reference/manifest.html>:

[profile.release]
opt-level =3D 'z'     # Optimize for size.
lto =3D true          # Enable Link Time Optimization
codegen-units =3D 1   # Reduce number of codegen units to increase
optimizations.
panic =3D 'abort'     # Abort on panic
strip =3D true        # Strip symbols from binary*

*strip =3D 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=C3=A1bado, 10/09/2022 =
=C3=A0(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 i=
t
> > 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 build
> 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
> contexts that happen to want something different override some
> default(s): opt out of the defaults.)
>
> =3D=3D=3D
> Mark Millard
> marklmi at yahoo.com
>
>
>

--=20
Nuno Teixeira
FreeBSD Committer (ports)

--000000000000576adc05e88c019d
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Hi,</div><div><br></div><div>I think this issue is re=
lated to what happened in terms of optimizations in go <span class=3D"eleme=
nt-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"e=
lement-details"></span><div>I&#39;ve found this optimizations interesting, =
e.g.:</div><div>---<br></div><div>The current high level steps to reduce bi=
nary size are:</div><div>
<ol><li>Use Rust 1.32.0 or newer (which doesn&#39;t include <code>jemalloc<=
/code> by default)</li><li>Add the following to <a href=3D"https://doc.rust=
-lang.org/cargo/reference/manifest.html" rel=3D"noreferrer"><code>Cargo.tom=
l</code></a>:</li></ol>[profile.release]<br>opt-level =3D &#39;z&#39; =C2=
=A0 =C2=A0 # Optimize for size.<br>lto =3D true =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0# Enable Link Time Optimization<br>codegen-units =3D 1 =C2=A0 # Redu=
ce number of codegen units to increase optimizations.<br>panic =3D &#39;abo=
rt&#39; =C2=A0 =C2=A0 # Abort on panic<br>strip =3D true =C2=A0 =C2=A0 =C2=
=A0 =C2=A0# Strip symbols from binary*<br><br>*strip =3D true requires Rust=
 1.59+. On older Rust versions, run strip manually on the resulting binary.=
</div><div>---</div><div><br></div><div>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&#39;s or should be upstream to implement a [profile.=
release]?</div><div><br></div><div>Cheers,<br></div></div><br><div class=3D=
"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">Mark Millard &lt;<a hre=
f=3D"mailto:marklmi@yahoo.com">marklmi@yahoo.com</a>&gt; escreveu no dia s=
=C3=A1bado, 10/09/2022 =C3=A0(s) 12:53:<br></div><blockquote class=3D"gmail=
_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204=
,204);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 build<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>
contexts 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>
marklmi at <a href=3D"http://yahoo.com" rel=3D"noreferrer" target=3D"_blank=
">yahoo.com</a><br>
<br>
<br>
</blockquote></div><br clear=3D"all"><br>-- <br><div dir=3D"ltr" class=3D"g=
mail_signature"><div dir=3D"ltr"><span style=3D"color:rgb(102,102,102)">Nun=
o Teixeira<br>FreeBSD Committer (ports)</span></div></div>

--000000000000576adc05e88c019d--



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