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

Issue 2552343003: First implementation of flat sets (Closed)

Created:
4 years ago by dyaroshev
Modified:
3 years, 10 months ago
CC:
chromium-reviews, vmpstr+watch_chromium.org, Alexander Yashkin
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

This patch introduces base::flat_set class in chromium. The interface is based on the proposal for standardisation: https://github.com/WG21-SG14/flat_containers/blob/master/proposals/P0460R0_flat_containers.md Differences in the api with the proposal: - Key types are not const. None of analysed flat_set implementations (boost, eastl, folly) do this. Making them const forbids erase(remove_if) idiom, which is widely believed to be the fastest way to erase elements from a vector - therefore from a flat_set. I've contacted Sean Middleditch (proposal's author) - he hasn't figure out this problem yet. - Ranges are represented with {Iterator/Iterator} pair vs {Iterator/Sentinel} pair. {Iterator/Sentinel} is an interface that is proposed for ranges from Ranges TS (talk at CppCon: https://youtu.be/mFUXNMfaciE). Currently in chromium we do not use this type of ranges, and introducing it without enable_if tricks make certain scenarios ambiguous. Example: base::flat_set<int> s; s.insert(s.begin(), 3); // Tries to insert with two template parameters instead of // casting iterator to const_iterator. We can probably fix this, but it should be done later. - No templated overloads of find/count/lower_bound etc. These overloads were introduced for std::set in C++14. They require a version of std::less<> without parameters. They are useful and we should implement them, but not in initial CL. - Default constructed iterators do not compare equal. Library working group issue: LWG #2059 We currently use std::vector iterators, and they do not do this in our version of the standard library. List of unclear issues: - Can we use libcpp tests? They seem to have permissive license, but this is not my area of expertise. Their license file on github: https://github.com/llvm-mirror/libcxx/blob/master/LICENSE.TXT - Do we want an interface that specialise allocators? There are a few possible variations of template parameters: proposal, boost: <Key, Compare, Allocator> eastl: <Key, Compare, Allocator, RandomAccessContainer /*allocator is passed here*/> another possibility: <Key, Compare, RandomAccessContainer> The possibility of customising underlying container seems to be useful for some cases in Chromium but it has to be investigated separately (this would lead to introduction of different apis, that have to be benchmarked first). However, we typically do not use allocators in chromium, do we want to keep the possibility of customising them in the interface, or do we want to rip it out? - Do we want to leave the possibility of a small buffer optimisation for default flat_set? std::vector does not invalidate iterators on move and swap, which forbids small buffer optimisation. This optimisation sometimes proves to be very beneficial. If we are willing not to give the same guarantee as std::vector, we can introduce it by default later. Discussion at chrome-dev: https://groups.google.com/a/chromium.org/forum/#!searchin/chromium-dev/vector$20based/chromium-dev/4uQMma9vj9w/HaQ-WvMOAwAJ Proposal to add flat_set to chromium: https://docs.google.com/document/d/1N9TeYduZj1OR4Qm_aEZ-hp5yq7HlpnGi06VThive5gw/edit?usp=sharing BUG=671759 Review-Url: https://codereview.chromium.org/2552343003 Cr-Commit-Position: refs/heads/master@{#448869} Committed: https://chromium.googlesource.com/chromium/src/+/db07be4db9751369102b24cd8fe772200982f3e7

Patch Set 1 : Initial commit #

Total comments: 10

Patch Set 2 : Review, round 1. #

Total comments: 80

Patch Set 3 : Review, round 2. #

Total comments: 34

Patch Set 4 : Review, round 3. #

Patch Set 5 : Review, round 4. #

Patch Set 6 : Fixing compilation error on linux. #

Total comments: 17

Patch Set 7 : Review, round 5. #

Patch Set 8 : Review, round 6. #

Total comments: 86

Patch Set 9 : Rewiew, round 7. #

Total comments: 20

Patch Set 10 : Review, round 8. #

Total comments: 32

Patch Set 11 : Review, round 9. #

Total comments: 2

Patch Set 12 : Review, round 10. #

Total comments: 2

Patch Set 13 : Review, round 11. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1902 lines, -0 lines) Patch
M base/BUILD.gn View 1 2 3 4 5 6 7 8 2 chunks +2 lines, -0 lines 0 comments Download
A base/containers/flat_set.h View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +656 lines, -0 lines 0 comments Download
A base/containers/flat_set_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +1244 lines, -0 lines 0 comments Download

Messages

Total messages: 81 (21 generated)
dyaroshev
Ping reviewers. Hi. I would like to continue working on this. I suspect that we ...
4 years ago (2016-12-09 17:13:08 UTC) #7
Peter Kasting
I'm not a base/ OWNER, so I'm not sure what sort of feedback you're looking ...
4 years ago (2016-12-12 20:34:30 UTC) #8
dyaroshev
On @pkasting said: I'm not a base/ OWNER, so I'm not sure what sort of ...
4 years ago (2016-12-15 14:28:00 UTC) #10
danakj
4 years ago (2016-12-15 15:08:42 UTC) #13
dyaroshev
https://codereview.chromium.org/2552343003/diff/40001/base/containers/flat_set.h File base/containers/flat_set.h (right): https://codereview.chromium.org/2552343003/diff/40001/base/containers/flat_set.h#newcode43 base/containers/flat_set.h:43: // Tests: This section does not make sense, since ...
4 years ago (2016-12-15 16:11:00 UTC) #14
Peter Kasting
https://codereview.chromium.org/2552343003/diff/40001/base/containers/flat_set.h File base/containers/flat_set.h (right): https://codereview.chromium.org/2552343003/diff/40001/base/containers/flat_set.h#newcode72 base/containers/flat_set.h:72: // private types much easier to declare before everything ...
4 years ago (2016-12-16 08:09:08 UTC) #15
dyaroshev
Make more libc++ tests more Chromium like. Originally didn't want to do it, so that ...
4 years ago (2016-12-18 22:27:25 UTC) #16
Peter Kasting
Have not re-reviewed https://codereview.chromium.org/2552343003/diff/40001/base/containers/flat_set.h File base/containers/flat_set.h (right): https://codereview.chromium.org/2552343003/diff/40001/base/containers/flat_set.h#newcode256 base/containers/flat_set.h:256: friend bool operator==(const flat_set& x, const ...
4 years ago (2016-12-18 22:47:43 UTC) #17
dyaroshev
On 2016/12/18 22:47:43, Peter Kasting wrote: > Have not re-reviewed > > https://codereview.chromium.org/2552343003/diff/40001/base/containers/flat_set.h > File ...
4 years ago (2016-12-18 23:07:14 UTC) #18
Peter Kasting
I think this is about as good as I can get things. One of the ...
4 years ago (2016-12-20 02:33:51 UTC) #19
dyaroshev
https://codereview.chromium.org/2552343003/diff/60001/base/containers/flat_set.h File base/containers/flat_set.h (right): https://codereview.chromium.org/2552343003/diff/60001/base/containers/flat_set.h#newcode47 base/containers/flat_set.h:47: // Current implementation is not particularly tweaked and based ...
3 years, 12 months ago (2016-12-20 21:59:56 UTC) #20
Peter Kasting
https://codereview.chromium.org/2552343003/diff/60001/base/containers/flat_set.h File base/containers/flat_set.h (right): https://codereview.chromium.org/2552343003/diff/60001/base/containers/flat_set.h#newcode248 base/containers/flat_set.h:248: // Flat sets are compared using operators defined for ...
3 years, 12 months ago (2016-12-20 22:06:39 UTC) #21
dyaroshev
On 2016/12/20 22:06:39, Peter Kasting wrote: > https://codereview.chromium.org/2552343003/diff/60001/base/containers/flat_set.h > File base/containers/flat_set.h (right): > > https://codereview.chromium.org/2552343003/diff/60001/base/containers/flat_set.h#newcode248 ...
3 years, 12 months ago (2016-12-20 22:15:01 UTC) #22
Peter Kasting
Reminder: Try and reply inline in the codereview tool if you can On 2016/12/20 22:15:01, ...
3 years, 12 months ago (2016-12-20 22:53:51 UTC) #23
dyaroshev
On 2016/12/20 22:53:51, Peter Kasting wrote: > Reminder: Try and reply inline in the codereview ...
3 years, 12 months ago (2016-12-20 23:46:29 UTC) #24
Peter Kasting
On 2016/12/20 23:46:29, dyaroshev wrote: > On 2016/12/20 22:53:51, Peter Kasting wrote: > > Reminder: ...
3 years, 12 months ago (2016-12-20 23:57:23 UTC) #25
dyaroshev
On 2016/12/20 23:57:23, Peter Kasting wrote: > On 2016/12/20 23:46:29, dyaroshev wrote: > > On ...
3 years, 12 months ago (2016-12-21 00:05:14 UTC) #26
dyaroshev
On 2016/12/20 23:57:23, Peter Kasting wrote: > Perhaps this could be resolved by splitting the ...
3 years, 12 months ago (2016-12-21 18:11:27 UTC) #27
Peter Kasting
On 2016/12/21 18:11:27, dyaroshev wrote: > On 2016/12/20 23:57:23, Peter Kasting wrote: > > > ...
3 years, 12 months ago (2016-12-21 20:08:34 UTC) #28
dyaroshev
On 2016/12/20 02:33:51, Peter Kasting wrote: > I think this is about as good as ...
3 years, 12 months ago (2016-12-23 21:49:14 UTC) #29
vmpstr
A lot of this functionality is what an std::set would provide. I feel like this ...
3 years, 11 months ago (2017-01-11 21:01:42 UTC) #31
Peter Kasting
On 2017/01/11 21:01:42, vmpstr wrote: > A lot of this functionality is what an std::set ...
3 years, 11 months ago (2017-01-11 21:32:05 UTC) #32
vmpstr
On 2017/01/11 21:32:05, Peter Kasting wrote: > On 2017/01/11 21:01:42, vmpstr wrote: > > A ...
3 years, 11 months ago (2017-01-11 21:51:51 UTC) #33
dyaroshev
On 2017/01/11 21:01:42, vmpstr wrote: > (I'm also not a base/ owner btw :) ) ...
3 years, 11 months ago (2017-01-16 06:58:02 UTC) #34
danakj
https://codereview.chromium.org/2552343003/diff/140001/base/containers/flat_set.h File base/containers/flat_set.h (right): https://codereview.chromium.org/2552343003/diff/140001/base/containers/flat_set.h#newcode53 base/containers/flat_set.h:53: // TODO(dyaroshev): research better algorithm for range insertion. On ...
3 years, 11 months ago (2017-01-16 15:21:44 UTC) #35
dyaroshev
On 2017/01/16 15:21:44, danakj (slow) wrote: > https://codereview.chromium.org/2552343003/diff/140001/base/containers/flat_set.h > File base/containers/flat_set.h (right): > > https://codereview.chromium.org/2552343003/diff/140001/base/containers/flat_set.h#newcode53 ...
3 years, 11 months ago (2017-01-17 10:25:14 UTC) #36
Peter Kasting
On 2017/01/17 10:25:14, dyaroshev wrote: > I respond to his reviews fully, I'm sorry if ...
3 years, 11 months ago (2017-01-17 18:06:12 UTC) #37
vmpstr
On 2017/01/17 18:06:12, Peter Kasting wrote: > On 2017/01/17 10:25:14, dyaroshev wrote: > > I ...
3 years, 11 months ago (2017-01-17 19:29:44 UTC) #38
dyaroshev
On 2017/01/17 19:29:44, vmpstr wrote: > On TODOs > ======== > My main concern about ...
3 years, 11 months ago (2017-01-18 16:16:04 UTC) #39
dyaroshev
On 2017/01/18 16:16:04, dyaroshev wrote: > On 2017/01/17 19:29:44, vmpstr wrote: > > On TODOs ...
3 years, 11 months ago (2017-01-18 16:29:40 UTC) #40
vmpstr
On 2017/01/18 16:29:40, dyaroshev wrote: > On 2017/01/18 16:16:04, dyaroshev wrote: > > On 2017/01/17 ...
3 years, 11 months ago (2017-01-19 20:40:58 UTC) #41
dyaroshev
message: On 2017/01/19 20:40:58, vmpstr wrote: > ... This CL looks good to me. Ping ...
3 years, 10 months ago (2017-01-24 14:22:11 UTC) #42
dcheng
+vmpstr who fell off the review thread somehow Sorry for the delay! I think danakj@ ...
3 years, 10 months ago (2017-01-26 19:36:48 UTC) #47
dcheng
On 2017/01/26 19:36:48, dcheng wrote: > +vmpstr who fell off the review thread somehow > ...
3 years, 10 months ago (2017-01-26 19:37:18 UTC) #48
vmpstr
This lgtm (as a non owner), I think the patch here is very straight forward. ...
3 years, 10 months ago (2017-01-26 19:42:19 UTC) #49
dcheng
Incidentally... can we provide a usage guide for when to use flat_set in this CL? ...
3 years, 10 months ago (2017-01-26 19:54:24 UTC) #50
dyaroshev
On 2017/01/26 19:54:24, dcheng wrote: > Incidentally... can we provide a usage guide for when ...
3 years, 10 months ago (2017-01-26 20:20:01 UTC) #51
danakj
> - Can we use libcpp tests? I believe we can. There is MIT licenced ...
3 years, 10 months ago (2017-01-26 23:18:05 UTC) #52
dyaroshev
@danakj - thank's for your review, I'll work on fixing your comments in a few ...
3 years, 10 months ago (2017-01-27 00:46:37 UTC) #53
danakj
https://codereview.chromium.org/2552343003/diff/180001/base/containers/flat_set.h File base/containers/flat_set.h (right): https://codereview.chromium.org/2552343003/diff/180001/base/containers/flat_set.h#newcode76 base/containers/flat_set.h:76: using key_type = Key; On 2017/01/27 00:46:36, dyaroshev wrote: ...
3 years, 10 months ago (2017-01-27 22:10:11 UTC) #54
dyaroshev
https://codereview.chromium.org/2552343003/diff/180001/base/containers/flat_set.h File base/containers/flat_set.h (right): https://codereview.chromium.org/2552343003/diff/180001/base/containers/flat_set.h#newcode1 base/containers/flat_set.h:1: // Copyright 2016 The Chromium Authors. All rights reserved. ...
3 years, 10 months ago (2017-01-30 00:07:13 UTC) #55
dyaroshev
Fix typo with next commit https://codereview.chromium.org/2552343003/diff/200001/base/containers/flat_set.h File base/containers/flat_set.h (right): https://codereview.chromium.org/2552343003/diff/200001/base/containers/flat_set.h#newcode31 base/containers/flat_set.h:31: // for different types ...
3 years, 10 months ago (2017-01-30 14:10:58 UTC) #56
danakj
https://codereview.chromium.org/2552343003/diff/180001/base/containers/flat_set.h File base/containers/flat_set.h (right): https://codereview.chromium.org/2552343003/diff/180001/base/containers/flat_set.h#newcode29 base/containers/flat_set.h:29: // benchmarks and tests for your code: beware of ...
3 years, 10 months ago (2017-01-30 20:24:31 UTC) #57
danakj
https://codereview.chromium.org/2552343003/diff/200001/base/containers/flat_set.h File base/containers/flat_set.h (right): https://codereview.chromium.org/2552343003/diff/200001/base/containers/flat_set.h#newcode276 base/containers/flat_set.h:276: std::stable_sort(begin(), end(), value_comp()); On 2017/01/30 00:07:13, dyaroshev wrote: > ...
3 years, 10 months ago (2017-01-30 20:28:38 UTC) #58
dyaroshev
On 2017/01/30 20:28:38, danakj (slow) wrote: > https://codereview.chromium.org/2552343003/diff/200001/base/containers/flat_set.h > File base/containers/flat_set.h (right): > > https://codereview.chromium.org/2552343003/diff/200001/base/containers/flat_set.h#newcode276 ...
3 years, 10 months ago (2017-01-30 22:28:06 UTC) #59
danakj
On Mon, Jan 30, 2017 at 5:28 PM, <dyaroshev@yandex-team.ru> wrote: > On 2017/01/30 20:28:38, danakj ...
3 years, 10 months ago (2017-01-30 22:39:18 UTC) #60
dyaroshev
> On danakj wrote: > I think that you should give some size limit in ...
3 years, 10 months ago (2017-01-31 23:08:26 UTC) #61
danakj
OK I feel u on the typedefs I guess. I would be expecting the stdlib ...
3 years, 10 months ago (2017-02-03 20:30:49 UTC) #62
dyaroshev
https://codereview.chromium.org/2552343003/diff/200001/base/containers/flat_set.h File base/containers/flat_set.h (right): https://codereview.chromium.org/2552343003/diff/200001/base/containers/flat_set.h#newcode343 base/containers/flat_set.h:343: auto flat_set<Key, Compare>::operator=(flat_set &&) -> flat_set& = default; On ...
3 years, 10 months ago (2017-02-04 00:59:16 UTC) #63
Peter Kasting
https://codereview.chromium.org/2552343003/diff/200001/base/containers/flat_set.h File base/containers/flat_set.h (right): https://codereview.chromium.org/2552343003/diff/200001/base/containers/flat_set.h#newcode343 base/containers/flat_set.h:343: auto flat_set<Key, Compare>::operator=(flat_set &&) -> flat_set& = default; On ...
3 years, 10 months ago (2017-02-04 01:03:35 UTC) #64
dcheng
https://codereview.chromium.org/2552343003/diff/200001/base/containers/flat_set.h File base/containers/flat_set.h (right): https://codereview.chromium.org/2552343003/diff/200001/base/containers/flat_set.h#newcode343 base/containers/flat_set.h:343: auto flat_set<Key, Compare>::operator=(flat_set &&) -> flat_set& = default; On ...
3 years, 10 months ago (2017-02-04 05:57:19 UTC) #65
danakj
LGTM w/ 2 last things: https://codereview.chromium.org/2552343003/diff/220001/base/containers/flat_set_unittest.cc File base/containers/flat_set_unittest.cc (right): https://codereview.chromium.org/2552343003/diff/220001/base/containers/flat_set_unittest.cc#newcode47 base/containers/flat_set_unittest.cc:47: MoveOnly(int data = 1) ...
3 years, 10 months ago (2017-02-07 16:35:51 UTC) #66
dyaroshev
> On 2017/02/03 20:30:49, danakj wrote: > L G T M Yey!!!!!!!!!!!! https://codereview.chromium.org/2552343003/diff/220001/base/containers/flat_set_unittest.cc File base/containers/flat_set_unittest.cc ...
3 years, 10 months ago (2017-02-07 23:47:24 UTC) #67
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2552343003/260001
3 years, 10 months ago (2017-02-07 23:48:59 UTC) #70
commit-bot: I haz the power
A disapproval has been posted by following reviewers: dcheng@chromium.org. Please make sure to get positive ...
3 years, 10 months ago (2017-02-07 23:49:07 UTC) #72
dyaroshev
On 2017/01/26 19:37:18, dcheng wrote: > On 2017/01/26 19:36:48, dcheng wrote: > > +vmpstr who ...
3 years, 10 months ago (2017-02-07 23:50:58 UTC) #73
dcheng
lgtm based on danakj's review https://codereview.chromium.org/2552343003/diff/260001/base/containers/flat_set.h File base/containers/flat_set.h (right): https://codereview.chromium.org/2552343003/diff/260001/base/containers/flat_set.h#newcode267 base/containers/flat_set.h:267: return !operator==(lhs, rhs); Nit: ...
3 years, 10 months ago (2017-02-07 23:54:45 UTC) #74
dyaroshev
https://codereview.chromium.org/2552343003/diff/260001/base/containers/flat_set.h File base/containers/flat_set.h (right): https://codereview.chromium.org/2552343003/diff/260001/base/containers/flat_set.h#newcode267 base/containers/flat_set.h:267: return !operator==(lhs, rhs); On 2017/02/07 23:54:45, dcheng wrote: > ...
3 years, 10 months ago (2017-02-08 00:07:22 UTC) #75
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2552343003/280001
3 years, 10 months ago (2017-02-08 00:08:37 UTC) #78
commit-bot: I haz the power
3 years, 10 months ago (2017-02-08 02:40:27 UTC) #81
Message was sent while issue was closed.
Committed patchset #13 (id:280001) as
https://chromium.googlesource.com/chromium/src/+/db07be4db9751369102b24cd8fe7...

Powered by Google App Engine
This is Rietveld 408576698