ConcurrentHashMap: Optimize iteration, empty, size, destruction.
Summary: ## Optimizations: - Avoid unnecessary creation of empty segments when iterating. - Keep track of the lowest and highest nonempty segments. ## Improvements: - Construction/destruction: ``` CHM ctor/dtor -- empty 213 ns 200 ns 196 ns CHM ctor/dtor -- 1 item 395 ns 388 ns 373 ns ``` ``` CHM ctor/dtor -- empty 99 ns 96 ns 94 ns CHM ctor/dtor -- 1 item 218 ns 217 ns 216 ns ``` - begin() before and after: ``` CHM begin() -- empty 705 ns 689 ns 660 ns ``` ``` CHM begin() -- empty 6 ns 6 ns 6 ns ``` - Iteration before and after: ``` CHM iterate -- empty 722 ns 714 ns 707 ns CHM iterate -- 1 item 621 ns 601 ns 587 ns CHM iterate -- 10 items 89 ns 88 ns 84 ns CHM iterate -- 100 items 55 ns 51 ns 48 ns CHM iterate -- 1K items 15 ns 14 ns 13 ns CHM iterate -- 10K items 13 ns 13 ns 12 ns CHM iterate -- 100K items 13 ns 12 ns 11 ns CHM iterate -- 1M items 36 ns 29 ns 27 ns CHM iterate -- 10M items 36 ns 35 ns 34 ns ``` ``` CHM iterate -- empty 7 ns 6 ns 6 ns CHM iterate -- 1 item 33 ns 32 ns 31 ns CHM iterate -- 10 items 27 ns 26 ns 26 ns CHM iterate -- 100 items 34 ns 33 ns 33 ns CHM iterate -- 1K items 10 ns 10 ns 10 ns CHM iterate -- 10K items 10 ns 9 ns 8 ns CHM iterate -- 100K items 9 ns 7 ns 7 ns CHM iterate -- 1M items 24 ns 19 ns 17 ns CHM iterate -- 10M items 27 ns 24 ns 23 ns ``` - empty() before and after: ``` CHM empty() -- empty 106 ns 104 ns 102 ns ``` ``` CHM empty() -- empty 1 ns 1 ns 1 ns ``` - size() before and after: ``` CHM size() -- empty 104 ns 101 ns 99 ns CHM size() -- 1 item 103 ns 101 ns 96 ns CHM size() -- 10 items 107 ns 106 ns 104 ns CHM size() -- 100 items 111 ns 100 ns 95 ns ``` ``` CHM size() -- empty 1 ns 1 ns 1 ns CHM size() -- 1 item 2 ns 2 ns 2 ns CHM size() -- 10 items 8 ns 8 ns 8 ns CHM size() -- 100 items 88 ns 71 ns 68 ns ``` Reviewed By: Gownta Differential Revision: D32684489 fbshipit-source-id: fb58277d6e58de0d95cca3c4274e1b08d182a45b
Showing
Please register or sign in to comment