[Bug libstdc++/67085] priority queue should not copy comparators when calling push_heap and pop_heap
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Jan 19 17:25:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67085
--- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The changes in r244150 turned some internal copies into moves, improving the PR
70898 testcase from 61 seconds to 29 seconds.
If I modify the testcase attached here to track moves as well as copies, GCC 6
prints:
Printing counts of numbers of calls to comparator copy + move constructors.
Before queue construction: 0 + 0
After queue construction : 4 + 0
After 3 calls to push : 16 + 0
After 3 calls to pop : 33 + 0
Since r244150 GCC 7 trunk prints:
Printing counts of numbers of calls to comparator copy + move constructors.
Before queue construction: 0 + 0
After queue construction : 2 + 2
After 3 calls to push : 8 + 8
After 3 calls to pop : 17 + 16
I'm testing a patch that reduces the PR 70898 test to under 4s and makes the
attachment here print:
Printing counts of numbers of calls to comparator copy + move constructors.
Before queue construction: 0 + 0
After queue construction : 1 + 3
After 3 calls to push : 4 + 12
After 3 calls to pop : 7 + 26
This doesn't help if your comparison function is only copyable and not movable,
but it's 2017 not 2007 so I think that's OK.
More information about the Gcc-bugs
mailing list