Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 6 Jan 2019 11:01:46 -0700
From:      Alan Somers <asomers@freebsd.org>
To:        Brian Neal <brian@aceshardware.com>
Cc:        "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org>
Subject:   Re: Speculative: Rust for base system components
Message-ID:  <CAOtMX2h-BGJZA-mEKgK8WPPhv4=SGDi%2BNWaKchw0u3FcDU5nLA@mail.gmail.com>
In-Reply-To: <e94efcba-3fd3-7d23-cc4a-bcc0af5a8851@aceshardware.com>
References:  <ca76e5f7-6e59-bd67-144a-90ad66f0252e@metricspace.net> <7d7bc47d-04cf-2f9b-00a3-e3d9d92b3623@aceshardware.com> <72922F2C-9D27-47AA-BB1C-2DA8589CF008@rpi.edu> <92bd5362-d898-aa12-8f3d-9fbe23f38e0c@aceshardware.com> <CAOtMX2gPrpO2O70pnwpU80bXMXo6LB9PCkU3bYw2ToMMnhf%2Bww@mail.gmail.com> <26325c0b-4960-7739-72aa-c31c4e0638d3@aceshardware.com> <CAOtMX2jOeAZfpyH1S1N1euAQQZe00nA9JQNjY2qnRB%2BczS9O2g@mail.gmail.com> <e94efcba-3fd3-7d23-cc4a-bcc0af5a8851@aceshardware.com>

next in thread | previous in thread | raw e-mail | index | archive | help
But it's not a like-for-like comparison.  Rust eliminates dead code at
a later stage.  If you want to compare the efficiency of generated
code, you need to exclude the dead code that will be eliminated by
LTO.  And you shouldn't be counting the labels for either language,
because they don't affect the machine code.  If you want to compare
build times, then you should actually measure build times.
-Alan

On Sun, Jan 6, 2019 at 10:51 AM Brian Neal <brian@aceshardware.com> wrote:
>
> Of course.  But I'm counting like for like.  So labels are counted for
> all languages.  And I definitely don't rely on LTO when comparing the
> efficacy of compiler, especially since the linker can spend lots of time
> eliminating dead-code (usually single-threaded), which means longer
> build times.
>
> On 1/6/2019 9:17 AM, Alan Somers wrote:
> > Those 21 lines aren't 21 instructions; you're counting labels.  Also,
> > the first three instructions aren't actually part of the function.
> > They're dead code, and should be eliminate by LTO.  However, Rust
> > doesn't do LTO when compiling libraries; only when linking
> > executables.  The unwrap logic, etc is also not part of the function.
> > So in this example, Rust produces only a few more instructions than C.
> > Also, FYI the Rust expression "0..num" is exclusive on the right.
> > It's equivalent to C's "for (int i = 0; i < num; i++)", though that
> > doesn't change the instruction count.
> >
> > -Alan
> _______________________________________________
> freebsd-hackers@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAOtMX2h-BGJZA-mEKgK8WPPhv4=SGDi%2BNWaKchw0u3FcDU5nLA>