3 ms·
How cache-friendly are zip/enumerate implementations? Zig is influenced by the ideas behind Data Oriented Design, mentioned in the article (and a buried lede, i
by cgh 4y ago
How cache-friendly are zip/enumerate implementations? Zig is influenced by the ideas behind Data Oriented Design, mentioned in the article (and a buried lede, if you ask me). Explicit for loops like this are generally cache-friendly and ideal for eg game programming, as shown in the structs of arrays example.
- vore 4y agoAs cache-friendly as advancing two pointers and a bounds check.
- deleted 4y ago[deleted]
- steveklabnik 4y agoI tossed together a simple function using enumerate https://godbolt.org/z/PKsEdKvKK https://godbolt.org/z/PKsEdKvKK You get the same exact asm as the manual loop. Of course, the idiom recognition seems to kick in, in both cases, as there's no actual loop here. I tossed in a +sum, which makes that fail, so you get some loops, check it out: https://godbolt.org/z/1ddf5ded7 https://godbolt.org/z/1ddf5ded7 They are one instruction different in length, which is kind of amusing to me. Some small differences.
- cgh 4y agoThanks, that’s exactly what I was asking. I don’t write Rust so it’s informative to see this.
- steveklabnik 4y agoAny time.