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

If you are sweating this level of performance, are larger gains possible by switching to C, C++, Rust? How is Rust for micro-managing memory layouts?


You need to do the exact same kinds of thing in C/C++/Rust. I believe Rust struct layout is not guaranteed to match program order unless you use an annotation forcing it (repr(C)). (So to answer the question: it's great; as good as any other language for micromanaging layout.)


Yes, without repr(C) order and padding isn't guaranteed. You would use https://docs.rs/crossbeam-utils/latest/crossbeam_utils/struc... or similar to force fields not being on the same cache line.


huh TIL

"On modern Intel architectures, spatial prefetcher is pulling pairs of 64-byte cache lines at a time, so we pessimistically assume that cache lines are 128 bytes long."


That was true in like, 2011. I'm not sure if it's true anymore.


Pretty sure it started being a thing at Sandy Bridge and never stopped?


I don't think the impact on adjacent cache lines is as severe as it was on Sandy Bridge.




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

Search: