Open yorickpeterse opened 1 month ago
IIRC lto = "thin"
is pretty much always a better choice compared to lto = true
. I however don't remember exactly what the impact is on compile times. I'm also not sure if blindly enabling this has any potential negative impact on certain platforms (I don't think so).
As for profiles: we already have a release-debug
profile that I occasionally use when doing performance debugging, as the regular release
profile sometimes doesn't include all the necessary debug info. While we can add release-lto
, I'd rather not do so as we'll quickly end up accumulating different and rarely used profiles. Instead, I'd either leave this up to package managers entirely or enable it by default if the compile times don't increase dramatically.
I did a quick test on my laptop, which is an X1 Carbon Gen 7 I think:
Profile | Time | inko size |
libinko.a size |
Program size (unstripped) | Program size (stripped) |
---|---|---|---|---|---|
release |
43 sec | 97 MiB | 31 MiB | 11 MiB | 3.6 MiB |
release-lto |
49.5 sec | 67 MiB | 41 MiB | 11 MiB | 3.6 MiB |
Here release-lto
is the release
profile combined with lto = "thin"
. The program is the following simple hello world program:
import std.stdio (Stdout)
class async Main {
fn async main {
Stdout.new.print('hello')
}
}
So using lto = "thin"
, the compile times increase by 15%, while the executable size is reduced by 30%. Oddly enough, the size of the shared runtime library (libinko.a
) increases, but the resulting executables remain the same size. For Inko's test suite I'm also not seeing a difference in the executable size.
Assuming different platforms (e.g. Arch Linux and Fedora) won't have any problems with lto = "thin"
being the default, and it works with all linkers (or silently ignores it if this isn't the case, instead of producing an error), I'd be fine with enabling this for the release
profile.
Discussed in https://github.com/orgs/inko-lang/discussions/769