Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Issue 2396533004: Introduce a FlatMap and FlatSet into WTF (Closed)

Created:
4 years, 2 months ago by alex clarke (OOO till 29th)
Modified:
4 years, 2 months ago
Reviewers:
haraken, Yuta Kitamura, Sami
CC:
chromium-reviews, blink-reviews, blink-reviews-wtf_chromium.org, scheduler-bugs_chromium.org, Mikhail
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Introduce a FlatMap and FlatSet into WTF Cache friendly data structures which outperform std::map<> and std::set<> for small or static datasets. This patch delivers a ~12% improvement to TaskQueueManagerPerfTest.RunTenThousandDelayedTasks_ThirtyTwoQueues. Measured on a z620 with the following steps taken to reduce noise: echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor taskset 1 out_linux/Release/blink_platform_perftests --gtest_filter=TaskQueueManagerPerfTest.RunTenThousandDelayedTasks_ThirtyTwoQueues Data: https://docs.google.com/spreadsheets/d/1qwsFxSay47rnd3YGs-TOVDxjjwNZKyOuIW8zOKWULVg/edit#gid=0 BUG=

Patch Set 1 #

Patch Set 2 : Add mising files #

Patch Set 3 : Chromium style #

Patch Set 4 : Fix compile #

Patch Set 5 : Rebased #

Patch Set 6 : Fix compile #

Total comments: 12

Patch Set 7 : Fix bug where search_step_size_ became zero #

Patch Set 8 : A first try at a perftest #

Patch Set 9 : Fix power of two check #

Patch Set 10 : Fix some issues with the perf test #

Patch Set 11 : Add missing ostream override #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1454 lines, -82 lines) Patch
M third_party/WebKit/Source/platform/scheduler/base/task_queue_impl.h View 1 2 2 chunks +9 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/platform/scheduler/base/time_domain.h View 1 2 3 4 5 6 7 8 9 10 4 chunks +10 lines, -13 lines 0 comments Download
M third_party/WebKit/Source/platform/scheduler/base/time_domain.cc View 1 2 3 4 5 6 7 8 9 10 7 chunks +45 lines, -56 lines 0 comments Download
M third_party/WebKit/Source/platform/scheduler/base/work_queue_sets.h View 2 chunks +2 lines, -1 line 0 comments Download
M third_party/WebKit/Source/platform/scheduler/base/work_queue_sets.cc View 1 2 3 4 chunks +8 lines, -11 lines 0 comments Download
M third_party/WebKit/Source/platform/scheduler/base/work_queue_sets_unittest.cc View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/wtf/BUILD.gn View 1 2 3 4 5 6 7 3 chunks +6 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/wtf/FlatMap.h View 1 2 3 4 5 6 7 8 9 1 chunk +119 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/wtf/FlatMapTest.cpp View 1 2 3 4 5 6 1 chunk +322 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/wtf/FlatSet.h View 1 2 3 4 5 6 7 8 9 1 chunk +68 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/wtf/FlatSetTest.cpp View 1 2 3 4 5 6 7 8 9 1 chunk +143 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/wtf/FlatTable.h View 1 2 3 4 5 6 7 8 9 10 1 chunk +432 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/wtf/SetPerfTest.cpp View 1 2 3 4 5 6 7 8 9 10 1 chunk +289 lines, -0 lines 0 comments Download

Messages

Total messages: 82 (68 generated)
alex clarke (OOO till 29th)
4 years, 2 months ago (2016-10-06 15:23:35 UTC) #18
alex clarke (OOO till 29th)
+haraken
4 years, 2 months ago (2016-10-06 16:44:58 UTC) #30
alex clarke (OOO till 29th)
BTW I think I'll split this up into two patches, and I'll try and add ...
4 years, 2 months ago (2016-10-06 17:37:58 UTC) #34
haraken
I want to hear an opinion of yutak@, who did a lot of investigations about ...
4 years, 2 months ago (2016-10-07 06:51:18 UTC) #36
Yuta Kitamura
First just let me check one thing: is this conceptually similar to google3's dense_hash_map? google3's ...
4 years, 2 months ago (2016-10-07 07:46:59 UTC) #37
Sami
Looks pretty neat. I'll leave it up to you guys to decide if this makes ...
4 years, 2 months ago (2016-10-07 09:49:11 UTC) #38
alex clarke (OOO till 29th)
On 2016/10/07 06:51:18, haraken wrote: > I want to hear an opinion of yutak@, who ...
4 years, 2 months ago (2016-10-07 12:02:32 UTC) #45
haraken
On 2016/10/07 12:02:32, alex clarke wrote: > On 2016/10/07 06:51:18, haraken wrote: > > I ...
4 years, 2 months ago (2016-10-07 12:07:36 UTC) #46
alex clarke (OOO till 29th)
On 2016/10/07 12:07:36, haraken wrote: > On 2016/10/07 12:02:32, alex clarke wrote: > > On ...
4 years, 2 months ago (2016-10-07 12:10:39 UTC) #47
alex clarke (OOO till 29th)
On 2016/10/07 07:46:59, Yuta Kitamura wrote: > First just let me check one thing: is ...
4 years, 2 months ago (2016-10-07 12:14:59 UTC) #50
Yuta Kitamura
OK let me take a look next week. (Monday is a national holiday in Japan, ...
4 years, 2 months ago (2016-10-07 12:32:22 UTC) #56
alex clarke (OOO till 29th)
On 2016/10/07 12:32:22, Yuta Kitamura wrote: > OK let me take a look next week. ...
4 years, 2 months ago (2016-10-10 18:27:09 UTC) #76
haraken
On 2016/10/10 18:27:09, alex clarke wrote: > On 2016/10/07 12:32:22, Yuta Kitamura wrote: > > ...
4 years, 2 months ago (2016-10-11 00:06:13 UTC) #77
alex clarke (OOO till 29th)
4 years, 2 months ago (2016-10-13 14:16:32 UTC) #82
Lets close this for now

https://codereview.chromium.org/2396533004/diff/120001/third_party/WebKit/Sou...
File third_party/WebKit/Source/wtf/FlatSet.h (right):

https://codereview.chromium.org/2396533004/diff/120001/third_party/WebKit/Sou...
third_party/WebKit/Source/wtf/FlatSet.h:65: DISALLOW_COPY_AND_ASSIGN(FlatSet);
On 2016/10/07 09:49:11, Sami wrote:
> STL containers are copyable and assignable -- is there a reason to be
different
> here?

Done.

https://codereview.chromium.org/2396533004/diff/120001/third_party/WebKit/Sou...
File third_party/WebKit/Source/wtf/FlatTable.h (right):

https://codereview.chromium.org/2396533004/diff/120001/third_party/WebKit/Sou...
third_party/WebKit/Source/wtf/FlatTable.h:141: // O(log n + n / 2)
On 2016/10/07 09:49:11, Sami wrote:
> Maybe document the return value?

Done.

https://codereview.chromium.org/2396533004/diff/120001/third_party/WebKit/Sou...
third_party/WebKit/Source/wtf/FlatTable.h:163: if (empty()) {
On 2016/10/07 09:49:11, Sami wrote:
> DCHECK that value is actually unique?
> 
> Edit: I guess InsertUniqueImpl kinda does that already.

Right, that should be enough?

https://codereview.chromium.org/2396533004/diff/120001/third_party/WebKit/Sou...
third_party/WebKit/Source/wtf/FlatTable.h:253: size_t
InsertUniqueImpl(value_type value) {
On 2016/10/07 09:49:11, Sami wrote:
> Maybe the great renaming will fix this but I find it a bit jarring that we're
> 50% chrome/blink style here with names :)

Done.

https://codereview.chromium.org/2396533004/diff/120001/third_party/WebKit/Sou...
third_party/WebKit/Source/wtf/FlatTable.h:323: void ComputeModulusMask() {
modulus_mask_ = ring_buffer_.size() - 1; }
On 2016/10/07 09:49:11, Sami wrote:
> DCHECK that this is 2^n-1?

Done something similar.

Powered by Google App Engine
This is Rietveld 408576698