"65% more instructions per packet with the Rust driver compared to C. But it does so with only 6% more cycles per packet" tl;dr: Rust's bounds checking is faster than you'd expect b/c superscalar CPU's have plenty of otherwise unused parallelism.https://github.com/ixy-languages/ixy-languages/blob/master/Rust-vs-C-performance.md …
-
Show this thread
-
Of course, you also have the option of turning off any bounds checking you want w/ unsafe. Better: You can often eliminate bounds checks with clever upfront usage of assert!(): basically *which* bounds check fails is often an observable change, so by…
1 reply 1 retweet 6 likesShow this thread -
…putting a bounds check at the beginning you help the compiler optimize away the rest of the bounds checks as a failed check would have already failed, making the remaining checks truly redundant and thus removable without a behavior change.
3 replies 1 retweet 6 likesShow this thread -
Replying to @peterktodd
Go doesn't have assert!(), but you can accomplish the same thing by accessing the maximum index at the top of your function: https://github.com/golang/go/blob/4e215554aa0e76e534327b9e6721971b9e82c113/src/crypto/aes/block.go#L45 …
1 reply 0 retweets 1 like -
Replying to @lukechampine
Go doesn't have assert()‽ Not even a debug version? That seems like a bad idea in general.
1 reply 0 retweets 0 likes -
Replying to @peterktodd
I mean, you can easily write your own, but it's not blessed by the language. Their argument is that assert makes programmers lazy: https://golang.org/doc/faq#assertions … Personally I'm ambivalent re: runtime asserts, but compile-time asserts seem like a clear win, and don't invite laziness.
2 replies 0 retweets 1 like
Luke Champine Retweeted Luke Champine
.@funcOfJoe wrote about a contract-like approach to asserts in Microsoft's Midori project that seemed both powerful and pragmatic: http://joeduffyblog.com/2016/02/07/the-error-model/ …
Also, I *did* find a great hack to achieve arbitrary compile-time asserts into Go...https://twitter.com/lukechampine/status/1026695476811390976 …
Luke Champine added,
-
-
Replying to @lukechampine @funcOfJoe
Rust's static_assertions crate does that kind of trick too: https://docs.rs/static_assertions/0.3.4/static_assertions/ …
0 replies 0 retweets 1 likeThanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.