Re:A single line of code made a 24-core server slower than a...
by Thiez on Friday December 31, 2021 @10:12AM
(#29748699)
Immutable collections wouldn't really help here since Rust does not have a garbage collector, so they would still be wrapped in an `Arc<T>`, or use one internally. Unless you're giving each thread their own copy of the immutable collection, in which case the immutability doesn't really add much.
[ Parent
| on HN ]
Re:A single line of code made a 24-core server slower than a...
by ericbarrett on Friday December 31, 2021 @11:33AM
(#29749581)
You're right if they're wrapped in an Arc<T>. But it's a lot easier to confidently clone an immutable data structure to threads/async functions because you know they won't be mutated by other cores. If you're cloning mutable data, you'll have to collect each "shard" at the end of whatever runtime loop your program has, and merge them back into the authoritative model. (Or drop the changes, but then why make the data mutable?) Gets hairy.