Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Could've sworn I've read somewhere the Rust maintainers stated that Rust will never have a switch to disable bounds checking. Has this changed?

Not having a switch to disable bounds checking is not the same as not being able to disable bounds checking.

> I don't know of any other specifics, but benchmarks usually show D outperform Rust (and often enough, everything else), e.g.:

It's been years since I saw those benchmarks. Those are benchmarks of the built-in library random number generator. Rust uses a more secure random number generator by default than most of the other languages, so it will go slower. If you really want to benchmark random number generation, pick a faster but less secure algorithm.



> Not having a switch to disable bounds checking is not the same as not being able to disable bounds checking.

Not sure what you're getting at. Marking the entire program as unsafe is not realistic. Marking specific portions leaves a long tail of code that "rarely" runs, but still adds up.

> Those are benchmarks of the built-in library random number generator.

The levgen-benchmarks programs implement the XOR-shift RNG in both the Rust and D versions.


> but still adds up.

No, it doesn't. Bounds checks in cold code don't matter (and there aren't many to begin with). Even bounds checks in hot code frequently don't matter. Have you profiled Rust code and found bounds checks to be a problem?

> The levgen-benchmarks programs implement the XOR-shift RNG in both the Rust and D versions.

Oh, I see that they changed it. Still, that benchmark is from 2013 and doesn't compile anymore. It predates unboxed closures and many other performance improvements. And 15% is in the "different register allocation decisions will affect the outcome" range, where comparisons are fairly meaningless. The fact that D and Rust beat C doesn't mean that they're faster than C.


> No, it doesn't. Bounds checks in cold code don't matter (and there aren't many to begin with). Even bounds checks in hot code frequently don't matter. Have you profiled Rust code and found bounds checks to be a problem?

I've measured some D code yesterday and it was like you said, bounds check didn't change performance which was very suprising (this was for JPEG loading).


I can't reply to pcwalton directly for some reason.

In reply to https://news.ycombinator.com/item?id=10139287 :

> No, it doesn't. Bounds checks in cold code don't matter (and there aren't many to begin with).

OK, I trust your expertise on this. The "long tail" applies to optimizations in general. I don't know why the benchmarks are slower for Rust then, could be the difference in backends.

> The fact that D and Rust beat C doesn't mean that they're faster than C.

I don't know what's going on there, but some languages allow writing fast code easier than in C, e.g. SIMD vector array operations.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: