This is the mail archive of the
mailing list for the GCC project.
Re: std::list iteration performance for under 1000 elements
- From: Florian Weimer <fweimer at redhat dot com>
- To: Soul Studios <matt at soulstudios dot co dot nz>
- Cc: gcc Mailing List <gcc at gcc dot gnu dot org>
- Date: Mon, 25 Apr 2016 08:11:05 +0200
- Subject: Re: std::list iteration performance for under 1000 elements
- Authentication-results: sourceware.org; auth=none
- References: <571D4E09 dot 2080508 at soulstudios dot co dot nz>
On 04/25/2016 12:51 AM, Soul Studios wrote:
I was wondering if any of you could explain this performance for me:
(full disclosure, this is my website and benchmarks - I just don't under
the std::list results I'm getting at the moment)
If you look at the iteration performance graphs, you'll see that
std::list under gcc (and MSVC, from further testing) has /really good/
forward-iteration performance for under 1000 elements (fewer elements
for larger datatypes).
Why is this. Everything I know about std::list's (non-contiguous memory
allocation, cache effect) implementation tells me it should have
terrible iteration performance. But for under 1000 elements it's often
better than std::deque?
Such questions should probably go to the help list.
You should look at this with perf, preferably counting cache misses. I
suspect that for working sets which fit into the first-level cache of
the CPU, the simpler iterators for std::list are faster than std::deque
because the additional memory accesses in std::list are cheaper than the
fairly complicated iterator implementation in std::deque.