4 ms·
The std::deque is also another useful 'hybrid' container that performs close to std::vector or better in some cases when you need to 'grow' the container withou
by rwbt 8y ago
The std::deque is also another useful 'hybrid' container that performs close to std::vector or better in some cases when you need to 'grow' the container without reallocating memory so many times. But the only good cache friendly implementation seems to be in clang libc++ (memory is allocated in 4KiB blocks). MSVC's deque implementation is horrible (8 byte blocks) and GCC's is also not that great (512 byte blocks).
- svantana 8y ago8 bytes??? Are you sure you don't mean 8 * sizeof(class)? That's just ridiculous. Regardless it would be nice if one could specify the block size as an argument. I suppose I could write my own allocator, but it's just too much hassle for such a simple thing as storage.
- rwbt 8y agoIf I remember correctly, in MSVC implementation if sizeof(T) is greater than 8 bytes then each 'block' is just one element (also blocks aren't contiguous). So effectively, MSVC implementation is useless. Boost does have a a deque container where you can specify the block size using type traits, but from my experience boost's deque wasn't such a good implementation performance wise. But Clang's libc++ implementation is very good performance wise and even beat std::vector in some cases.
- s3cur3 8y agoWorse, this is not on the table to be fixed any time soon in MSVC, because the change would break ABI compatibility. Every time someone says "just use a custom allocator," I sigh inside... it's so much overhead that almost no one does it, and even fewer do it correctly. :(