News for hackers. Stuff that matters.
Re:Things you can’t do in Rust (and what to do instead) by volta83 on Sunday May 16, 2021 @06:04AM (#27172571)
Nobody here is talking about vectors of integers. From the first post, this is all assuming that the objects in the vector are "big".

A modern CPU has 200Gb/s of bandwidth. If the objects in your array are 200 Gb in size each, then swapping the position of two elements in a vector is going to take O(seconds) at memcpy speeds, while doing this with a linked list is going to take ~1 * 10^(-11) seconds.

That's a performance difference of 11 orders of magnitude...

You can make the objects in the array smaller (e.g. 200Mb each instead of 200Gb each) and your two-element swap would still be 10^8 times faster with a doubly linked list.

---

In the parallel threads, people seem to just be arguing that a vector is always faster than a list, without understanding "why" this is the case, and making claims about "what the hardware does" without doing basic rule-of-thumb calculations to verify their claims.

Re:Things you can’t do in Rust (and what to do instead) by myrrlyn on Sunday May 16, 2021 @06:24PM (#27177593)
the good news is that a vector of any object can be reduced to a vector of integers by `Box`ing, and then you only incur a miss when you access the data, but not during every step you take to find the data
Re:Things you can’t do in Rust (and what to do instead) by kd5bjo on Tuesday May 18, 2021 @01:51AM (#27191614)
> A modern CPU has 200Gb/s of bandwidth. If the objects in your array are 200 Gb in size each, then swapping the position of two elements in a vector is going to take O(seconds) at memcpy speeds,

Not necessarily. If those items are aligned to a memory-page boundary, memcpy will probably do a page table update instead of actually moving the values in RAM.