you are viewing a single comment's thread
view the rest of the comments
[+] -23 points 1 year ago* (last edited 1 year ago) (44 children)

Rust running slower than C?

Never would have guessed……

Edit: LMAO

  • source
  • hideshow 44 child comments
  • [–] 36 points 1 year ago* (last edited 1 year ago) (41 children)

    The ill-informed Rust hatred goes in the Phoronix comments. Rust isn't inherently slower than C. This was a bug.

  • source
  • parent
  • hideshow 41 child comments
  • [–] 15 points 1 year ago (11 children)

    Looks like it wasn't even a bug, just a missed opportunity to use SIMD.

  • source
  • parent
  • hideshow 11 child comments
  • [–] -4 points 1 year ago (10 children)

    Did þe C version get þe same SIMD TLC?

  • source
  • parent
  • hideshow 10 child comments
  • [–] 16 points 1 year ago (9 children)

    Πρεσυμαβλυ, ἰτ ἀλρεαδυ ὐσεδ ΣΙΜΔ, ἀνδ θατ'ς ὁ θε ἐξιστινγ ΓΝΥ ὐτιλιτυ βεατ ῾Ρυστ βυ ἀ φακτορ ὀφ 17ξ.

  • source
  • parent
  • hideshow 9 child comments
  • [–] 9 points 1 year ago (8 children)

    Has someone who can mostly read Greek and English. I hate this. I hate this so much.

  • source
  • parent
  • hideshow 8 child comments
  • [–] 2 points 1 year ago (5 children)

    It's actually just English with Greek letters, just as the user above writes in English but uses the þ (thorn) character.

  • source
  • parent
  • hideshow 5 child comments
  • [–] 1 point 1 year ago (2 children)

    I've been trying to read it for a couple minutes now and I feel like I'm too dumb to realize what it's saying.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 0 points 1 year ago (28 children)

    I think it's fair to say performance rust is hard to write

  • source
  • parent
  • hideshow 28 child comments
  • [–] 10 points 1 year ago (21 children)

    I have no idea how. I write better Rust than I do C 🤷‍♂️

    Rust and C are basically identical in terms of performance (more or less). Idk where the myth that Rust is somehow less performant than C came from.

  • source
  • parent
  • hideshow 21 child comments
  • [–] 0 points 1 year ago (20 children)

    It depends on what you are counting as "performance"

    Good C code is way better than mediocre Rust code. C also has much smaller binaries.

  • source
  • parent
  • hideshow 20 child comments
  • [–] 6 points 1 year ago* (last edited 1 year ago) (1 child)

    "Thing I say is good, is better than thing I say is mediocre."

    Indeed.

  • source
  • parent
  • hideshow 1 child comment
  • [–] -3 points 1 year ago

    But will a good hello world program, made in JS, run on Firefox on an Embedded Windows 11 OS, running on a CPU emulator running on WASM on Edge be more performant than a mediocre hello world program in C, running on Linux on the same hardware that Edge run on?

  • source
  • parent
  • [–] 5 points 1 year ago (15 children)

    If your goal is small binaries, it's possible to get them with Rust, too: https://github.com/johnthagen/min-sized-rust

    There are a variety of reasons why Rust binaries tend to be bigger unless you follow some of those guidelines, but the biggest one (and actually not something those guidelines recommend changing!) is that C is generally dynamically linked against a system version of the C standard library, whereas Rust binaries are statically linked by default, meaning that the binary is actually self-contained.

  • source
  • parent
  • hideshow 15 child comments
  • [–] 1 point 1 year ago (8 children)

    whereas Rust binaries are statically linked by default, meaning that the binary is actually self-contained.

    rust still produces larger binaries even if you compare it to static C binaries.

    Take for example busybox, you can compile all of it as a single 1.2 MiB static binary that provides 395 utilities including wget.

    Meanwhile the uutils static musl binary is 12 MiB and only provides 115 utilities.

  • source
  • parent
  • hideshow 8 child comments
  • [–] 2 points 1 year ago (7 children)

    That's not a fair comparison at all. Busybox is specifically optimized for size, and to accomplish that, leaves out a large number of GNU compatibility features; uutils is designed to mimic GNU as closely as possible, and I'm assuming that the binary you're looking at is not the "small-release" build. Just to see what that looks like, I've built it that way now and that puts it under 7 MiB; still much larger than busybox, but it shows how much the optimization choices matter.

  • source
  • parent
  • hideshow 7 child comments
  • [–] -2 points 1 year ago* (last edited 1 year ago) (6 children)

    That’s not a fair comparison at all. Busybox is specifically optimized for size, and to accomplish that, leaves out a large number of GNU compatibility features

    Such as? busybox provides a nice interactive shell, awk, bc, wget and much more. I know GNU awk has a lot more features than posix awk but awk is not part of the uutils anyways.

    busybox also implements [[ from bash, none of this is provided by uutils or coreutils.

    EDIT: busybox also provides grep while the uutils/coreutils don't.

    I’ve built it that way now and that puts it under 7 MiB; still much larger than busybox, but it shows how much the optimization choices matter.

    I'm assuming this uses -Os which means performance hit, (iirc busybox also uses -Os so it is fair comparison), still we are looking at 7x larger binary.

  • source
  • parent
  • hideshow 6 child comments
  • [–] 3 points 1 year ago (5 children)

    From the busybox "about" page:

    The utilities in BusyBox generally have fewer options than their full-featured GNU cousins; however, the options that are included provide the expected functionality and behave very much like their GNU counterparts.... BusyBox has been written with size-optimization and limited resources in mind.

    Neither of these is true for uutils, which is specifically targeting perfect GNU compatibility. I don't think there is a comparable Rust project for minimized utilities.

  • source
  • parent
  • hideshow 5 child comments
  • [–] 0 points 1 year ago (4 children)

    The utilities in BusyBox generally have fewer options than their full-featured GNU cousins

    Note: GNU cousins, not GNU coreutils.

    GNU awk, GNU grep, bash, wget, etc will give you a lot more features than the busybox equivalents. However the uutils nor coreutils implement those features at all.

    If anything the comparison is not being fair to busybox because busybox implements a lot more utilities.

  • source
  • parent
  • hideshow 4 child comments
  • [–] 3 points 1 year ago (3 children)

    Busybox ls has 26 flags. GNU ls has 60.

  • source
  • parent
  • hideshow 3 child comments
  • [–] 0 points 1 year ago (2 children)

    fair, in that case the comparison is even since busybox provides a shell, awk, grep, wget among other 395 utils, uutils it is 115.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 3 points 1 year ago (1 child)

    I really don't think these are clearly comparable. I would rather see two more similar projects with comparable functionality that are both attempting to optimize for program binary size.

  • source
  • parent
  • hideshow 1 child comment
  • [–] -3 points 1 year ago (5 children)

    C is still better for the embedded world

    If you have gigabytes of storage and memory Rust makes more sense. C shines as it allows fine control over memory. The fact that you can tie into The system libraries makes it very resource friendly since you don't need redundant code.

  • source
  • parent
  • hideshow 5 child comments
  • [–] 5 points 1 year ago (2 children)

    I think you're making some poorly-researched assumptions.

    In the embedded world, there often aren't "system libraries," depending on just what you're targeting. But if, for some reason, you really do want to use libc but not the Rust standard library, you can certainly do that; for instance, here's a crate that reimplements the Rust standard library's output and formatting capabilities using libc: https://github.com/mmastrac/rust-libc-print

    Rust provides essentially the same memory control as C does. You can also have inline assembly in Rust, just as in C.

  • source
  • parent
  • hideshow 2 child comments
  • You can tailor the rust standard library to be more embedded friendly in several way, like if you don't have dynamic memory allocation or a filesystem, you can get the standard library sans those features.

    Rust also gives you a very fine grained level of control of memory, I think equivalent to C (maybe there's some gotcha that I'm not aware of but if not equivalent very close).

    It really doesn't sound like you know that much about Rust here and are just making things up, you certainly don't need "gigabytes of storage and memory"

  • source
  • parent
  • [–] 4 points 1 year ago* (last edited 1 year ago) (1 child)

    think it's fair to say performance rust is hard to write

    This situation proved exactly the opposite.

    They wrote a utility to pass functional tests. It did. Then people said it was too slow. So, in just a few days or hours, they dramatically sped it up while still passing the tests.

    Seems like it was pretty easy to write fast Rust code in this case.

  • source
  • parent
  • hideshow 1 child comment
  • [–] 1 point 1 year ago

    Fair point. I am mostly going on what I have seen others do on streams when comparing rust and go. Go seemed faster to get good performance and rust sometimes had to write a ton of code to get the same performance.

    I don't know if you can selectively not use Go's garbage collector, but that seems to be the only reason Go might be theoretically slower than rust.

  • source
  • parent
  • [–] 8 points 1 year ago* (1 child)

    The best thing about all the C smugness here is how quickly it backfired.

    Out of dozens of utilities in uutils, two were slower than the GNU equivalents. In case the logic escapes some, that means that the others were already as fast or faster. Some are multiples faster. The overall uutils suite is faster then GNU Coreutils already and will only get better. There was nothing for C fans to be smug about to begin with.

    Of the two that were slower, it seems to have only taken a few days to make them faster. The article only tells us about one which is now 50% faster than the GNU version.

    But the promise of Rust is not that Rust is faster anyway. It is that it is easier and safer to refactor. The actual promise of Rust is that you can address issues like performance without as much fear that you will break everything.

    After the reported slowness, both of the two uutils implementations were dramatically sped up in just a couple of days or even hours. They are tested against the GNU test suite and so we know these tests are still passing. That is the promise of Rust. This example proves the Rust claims real. The C smugness did not age well.

    The C versions (GNU) can clearly be sped up as well. The question is who will do that and when. Because speeding up old C code is not nearly as easy or fun. My guess is that it is going to be more than a couple days before we see headlines bragging that GNU has caught up.

    The GNU Coreutils are maintained by Red Hat if we look at who contributes the code and who maintains the dev servers. They are professionally maintained. It is not a rag tag bunch of amateurs. So if uutils is already faster, it does not bode well for the C implementation.

  • source
  • parent
  • hideshow 1 child comment
  • [–] 1 point 1 year ago

    The overall uutils suite is faster then GNU Coreutils already and will only get better

    just did a quick benchmark.

    uutils cat is 2x slower.

    This is the unknown-linux-gnu release, the musl one is likely slower but didn't check.

  • source
  • parent