How much does Rust's bounds checking cost?
blog.readyset.io
How much does Rust's bounds checking cost?
1–10 of 195 posts
Re: How much does Rust's bounds checking cost?
#2 go build -gcflags=-B
and see if it helps. Generally the assembly looks better, but it doesn't really run faster on a modern chip.Do your own test, and keep the results in mind next time somebody on Hacker News dismisses Go because of the "overwhelming cost of bounds checking".
Re: How much does Rust's bounds checking cost?
#3Re: How much does Rust's bounds checking cost?
#4... that being said, I'd argue that the most beneficial memory-safety feature of Rust is about temporal things (i.e. prevents UAF etc) instead of spatial ones.
Re: How much does Rust's bounds checking cost?
#5Re: How much does Rust's bounds checking cost?
#6I would expect an iterator into a slice to not incur any bounds checking, as the compiler can deduce the end pointer one time as start + size. So idiomatic looping should be maximally efficient you'd hope.
Re: How much does Rust's bounds checking cost?
#7A consistent 5 ms difference in micro-benchmarks is definitely not "measurement noise". Noise averages out way before accumulating to 5ms. There must be a reason and it mostly likely relates to the change. So you can confidently say that removing bounds checking (at least with how you did it) is a regression. ... that being said, I'd argue that the most beneficial memory-safety feature of Rust is about temporal thing…
Re: How much does Rust's bounds checking cost?
#8Re: How much does Rust's bounds checking cost?
#9Similarly, you can turn off bounds-checking in Go like this: go build -gcflags=-B and see if it helps. Generally the assembly looks better, but it doesn't really run faster on a modern chip. Do your own test, and keep the results in mind next time somebody on Hacker News dismisses Go because of the "overwhelming cost of bounds checking".
That’s certainly one criticism I don’t remember ever seeing.
Re: How much does Rust's bounds checking cost?
#10Can someone smarter than me enlighten me when you would consider disabling bounds checking for performance? In ways the compiler is not already doing so? The article starts with a bug that would have been prevented by bounds checking. It's like talking about how much faster a car would go if it didn't have to carry the extra weight of brakes.
And there’s folks who do exactly that.