4 ms·
While I am an advocate of straight C programming, I wonder if his issues with his person list in c++ vs a person dlink list implementation was an incorrect comp
by fein 14y ago
While I am an advocate of straight C programming, I wonder if his issues with his person list in c++ vs a person dlink list implementation was an incorrect comparison.
stl vector would have been the proper "optimized" way of implementing that list of people in c++, as vectors don't deal with the heap. If your vector's memory space can fit entirely in L2, we're looking at IMMENSE performance increases.
- tptacek 14y agovectors don't deal with the heap? Huh? Yes they do.
- astrodust 14y agoI think the comment was a bad phrasing of "a vector is a contiguous memory structure, whereas a list is a series of independent allocations at various points in the heap".
- tptacek 14y agoSure, but also remember that while vectors are better at locality, both vectors and lists can trash the heap; both are making variable sized requests on demand from the allocator.
- tedunangst 14y agoEvery time I've had to deal with fragmentation, it was due to a small number of large objects. Never large numbers of small objects. ymmv.
- tptacek 14y agoVery definitely not my experience.
- tedunangst 14y agoDidn't mean to imply it was always the case. Just a counterpoint to the conventional wisdom that fragmentation is only a problem with lots of tiny objects.
- tptacek 14y agoSorry, we always sound snippy on message boards. I'm not That Guy in real life. Wait no I totally am.
- scott_s 14y agoWhich is probably thanks to a good memory allocator.
- Daniel_Newby 14y agoI think fein meant heap allocators and deallocators, which vectors rarely use if you are careful.