[libcxx-commits] [PATCH] D62779: [2/2] Fix complexity of map insert_or_assign with a hint.
Mark de Wever via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Jun 1 09:30:08 PDT 2019
Mordante created this revision.
Mordante added a reviewer: mclow.lists.
Herald added a subscriber: christof.
Herald added a project: libc++.
In bug 38722 Mitsuru Kariya reported the map operations insert_or_assign with a hint violates the complexity requirement. The function no longer uses a lower_bound, which caused the wrong complexity.
This fixes bug 38722.
Benchmarked with:
Run on (4 X 3400 MHz CPU s)
CPU Caches:
L1 Data 32K (x4)
L1 Instruction 32K (x4)
L2 Unified 256K (x4)
L3 Unified 6144K (x1)
Timing before:
-----------------------------------------------------------------------------------------------
Benchmark Time CPU Iterations
-----------------------------------------------------------------------------------------------
BM_InsertAssignHint_MapSize=10_ExistingElement 6.99 ns 6.98 ns 121900000
BM_InsertAssignHint_MapSize=100_ExistingElement 14.4 ns 14.4 ns 48800000
BM_InsertAssignHint_MapSize=1000_ExistingElement 43.0 ns 43.0 ns 17000000
BM_InsertAssignHint_MapSize=10000_ExistingElement 56.5 ns 56.5 ns 11000000
BM_InsertAssignHint_MapSize=100000_ExistingElement 116 ns 116 ns 6000000
BM_InsertAssignHint_MapSize=1000000_ExistingElement 154 ns 154 ns 5000000
BM_InsertAssignHint_MapSize=10_NewElement 28.4 ns 28.4 ns 24690000
BM_InsertAssignHint_MapSize=100_NewElement 72.4 ns 72.4 ns 12600000
BM_InsertAssignHint_MapSize=1000_NewElement 74.3 ns 74.3 ns 9000000
BM_InsertAssignHint_MapSize=10000_NewElement 92.4 ns 92.4 ns 7000000
BM_InsertAssignHint_MapSize=100000_NewElement 151 ns 151 ns 5000000
BM_InsertAssignHint_MapSize=1000000_NewElement 194 ns 194 ns 4000000
-----------------------------------------------------------------------------------------------
Benchmark Time CPU Iterations
-----------------------------------------------------------------------------------------------
BM_InsertAssignHint_MapSize=10_ExistingElement 6.96 ns 6.96 ns 123030000
BM_InsertAssignHint_MapSize=100_ExistingElement 14.5 ns 14.4 ns 48600000
BM_InsertAssignHint_MapSize=1000_ExistingElement 43.0 ns 43.0 ns 17000000
BM_InsertAssignHint_MapSize=10000_ExistingElement 56.7 ns 56.7 ns 11000000
BM_InsertAssignHint_MapSize=100000_ExistingElement 116 ns 116 ns 6000000
BM_InsertAssignHint_MapSize=1000000_ExistingElement 153 ns 153 ns 5000000
BM_InsertAssignHint_MapSize=10_NewElement 28.6 ns 28.6 ns 24600000
BM_InsertAssignHint_MapSize=100_NewElement 76.2 ns 76.2 ns 12600000
BM_InsertAssignHint_MapSize=1000_NewElement 74.6 ns 74.6 ns 9000000
BM_InsertAssignHint_MapSize=10000_NewElement 92.4 ns 92.4 ns 7000000
BM_InsertAssignHint_MapSize=100000_NewElement 151 ns 151 ns 4000000
BM_InsertAssignHint_MapSize=1000000_NewElement 194 ns 194 ns 3000000
-----------------------------------------------------------------------------------------------
Benchmark Time CPU Iterations
-----------------------------------------------------------------------------------------------
BM_InsertAssignHint_MapSize=10_ExistingElement 6.96 ns 6.96 ns 122840000
BM_InsertAssignHint_MapSize=100_ExistingElement 14.5 ns 14.5 ns 49000000
BM_InsertAssignHint_MapSize=1000_ExistingElement 43.0 ns 43.0 ns 17000000
BM_InsertAssignHint_MapSize=10000_ExistingElement 56.4 ns 56.4 ns 11000000
BM_InsertAssignHint_MapSize=100000_ExistingElement 116 ns 116 ns 6000000
BM_InsertAssignHint_MapSize=1000000_ExistingElement 154 ns 154 ns 4000000
BM_InsertAssignHint_MapSize=10_NewElement 28.3 ns 28.3 ns 24830000
BM_InsertAssignHint_MapSize=100_NewElement 76.1 ns 76.1 ns 12500000
BM_InsertAssignHint_MapSize=1000_NewElement 74.7 ns 74.7 ns 9000000
BM_InsertAssignHint_MapSize=10000_NewElement 92.8 ns 92.8 ns 7000000
BM_InsertAssignHint_MapSize=100000_NewElement 150 ns 150 ns 4000000
BM_InsertAssignHint_MapSize=1000000_NewElement 197 ns 197 ns 3000000
Timing after:
-----------------------------------------------------------------------------------------------
Benchmark Time CPU Iterations
-----------------------------------------------------------------------------------------------
BM_InsertAssignHint_MapSize=10_ExistingElement 4.30 ns 4.30 ns 167310000
BM_InsertAssignHint_MapSize=100_ExistingElement 8.18 ns 8.18 ns 85400000
BM_InsertAssignHint_MapSize=1000_ExistingElement 8.11 ns 8.11 ns 87000000
BM_InsertAssignHint_MapSize=10000_ExistingElement 8.11 ns 8.11 ns 87000000
BM_InsertAssignHint_MapSize=100000_ExistingElement 8.28 ns 8.28 ns 83000000
BM_InsertAssignHint_MapSize=1000000_ExistingElement 8.63 ns 8.62 ns 82000000
BM_InsertAssignHint_MapSize=10_NewElement 23.5 ns 23.4 ns 30110000
BM_InsertAssignHint_MapSize=100_NewElement 63.2 ns 63.0 ns 10000000
BM_InsertAssignHint_MapSize=1000_NewElement 46.7 ns 46.6 ns 15000000
BM_InsertAssignHint_MapSize=10000_NewElement 41.8 ns 41.7 ns 13000000
BM_InsertAssignHint_MapSize=100000_NewElement 42.3 ns 42.1 ns 15000000
BM_InsertAssignHint_MapSize=1000000_NewElement 47.9 ns 47.7 ns 14000000
-----------------------------------------------------------------------------------------------
Benchmark Time CPU Iterations
-----------------------------------------------------------------------------------------------
BM_InsertAssignHint_MapSize=10_ExistingElement 4.30 ns 4.30 ns 167500000
BM_InsertAssignHint_MapSize=100_ExistingElement 8.39 ns 8.39 ns 84800000
BM_InsertAssignHint_MapSize=1000_ExistingElement 8.14 ns 8.15 ns 86000000
BM_InsertAssignHint_MapSize=10000_ExistingElement 8.12 ns 8.12 ns 87000000
BM_InsertAssignHint_MapSize=100000_ExistingElement 8.37 ns 8.37 ns 85000000
BM_InsertAssignHint_MapSize=1000000_ExistingElement 8.61 ns 8.61 ns 82000000
BM_InsertAssignHint_MapSize=10_NewElement 23.4 ns 23.4 ns 29830000
BM_InsertAssignHint_MapSize=100_NewElement 66.8 ns 66.8 ns 10000000
BM_InsertAssignHint_MapSize=1000_NewElement 46.6 ns 46.6 ns 14000000
BM_InsertAssignHint_MapSize=10000_NewElement 41.3 ns 41.4 ns 14000000
BM_InsertAssignHint_MapSize=100000_NewElement 41.7 ns 41.7 ns 14000000
BM_InsertAssignHint_MapSize=1000000_NewElement 48.5 ns 48.5 ns 11000000
-----------------------------------------------------------------------------------------------
Benchmark Time CPU Iterations
-----------------------------------------------------------------------------------------------
BM_InsertAssignHint_MapSize=10_ExistingElement 4.27 ns 4.27 ns 166850000
BM_InsertAssignHint_MapSize=100_ExistingElement 8.53 ns 8.53 ns 85100000
BM_InsertAssignHint_MapSize=1000_ExistingElement 8.31 ns 8.31 ns 86000000
BM_InsertAssignHint_MapSize=10000_ExistingElement 8.17 ns 8.18 ns 86000000
BM_InsertAssignHint_MapSize=100000_ExistingElement 8.73 ns 8.73 ns 82000000
BM_InsertAssignHint_MapSize=1000000_ExistingElement 8.98 ns 8.98 ns 81000000
BM_InsertAssignHint_MapSize=10_NewElement 24.6 ns 24.6 ns 29720000
BM_InsertAssignHint_MapSize=100_NewElement 71.9 ns 71.9 ns 10000000
BM_InsertAssignHint_MapSize=1000_NewElement 46.1 ns 46.1 ns 13000000
BM_InsertAssignHint_MapSize=10000_NewElement 41.7 ns 41.8 ns 14000000
BM_InsertAssignHint_MapSize=100000_NewElement 42.1 ns 42.1 ns 13000000
BM_InsertAssignHint_MapSize=1000000_NewElement 48.6 ns 48.6 ns 13000000
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D62779
Files:
libcxx/include/__tree
libcxx/include/map
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62779.202559.patch
Type: text/x-patch
Size: 3769 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190601/425e165e/attachment.bin>
More information about the libcxx-commits
mailing list