WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
155552
Implement SmallPtrSet and integrate it into the Parser
https://bugs.webkit.org/show_bug.cgi?id=155552
Summary
Implement SmallPtrSet and integrate it into the Parser
Saam Barati
Reported
2016-03-16 11:52:18 PDT
This data structure will use an inline array when the set is small. It won't have a remove operation. This should help speed up some of the HashSets we use inside the parser. It'll also be helpful in other places. See
http://llvm.org/docs/doxygen/html/SmallPtrSet_8h_source.html
Attachments
WIP
(19.05 KB, patch)
2016-03-17 02:06 PDT
,
Saam Barati
no flags
Details
Formatted Diff
Diff
perf numbers
(69.43 KB, text/plain)
2016-03-17 15:24 PDT
,
Saam Barati
no flags
Details
patch
(28.15 KB, patch)
2016-03-17 17:32 PDT
,
Saam Barati
no flags
Details
Formatted Diff
Diff
patch
(28.84 KB, patch)
2016-03-17 17:37 PDT
,
Saam Barati
no flags
Details
Formatted Diff
Diff
patch
(28.83 KB, patch)
2016-03-17 17:42 PDT
,
Saam Barati
no flags
Details
Formatted Diff
Diff
patch
(28.85 KB, patch)
2016-03-17 17:44 PDT
,
Saam Barati
fpizlo
: review+
Details
Formatted Diff
Diff
Show Obsolete
(4)
View All
Add attachment
proposed patch, testcase, etc.
Saam Barati
Comment 1
2016-03-17 02:06:04 PDT
Created
attachment 274272
[details]
WIP might be ready.
Saam Barati
Comment 2
2016-03-17 02:06:26 PDT
I've been getting about a 1.5-2.5% octane/code-load speed up from this.
Saam Barati
Comment 3
2016-03-17 15:24:27 PDT
Created
attachment 274328
[details]
perf numbers looks like a code-load progression. Will post patch soon.
Saam Barati
Comment 4
2016-03-17 17:32:44 PDT
Created
attachment 274344
[details]
patch
Saam Barati
Comment 5
2016-03-17 17:33:43 PDT
Comment on
attachment 274344
[details]
patch View in context:
https://bugs.webkit.org/attachment.cgi?id=274344&action=review
> Source/JavaScriptCore/parser/Parser.h:195 > + Scope(Scope&& rhs)
Actually, with vector.constructAndAppend(...) we don't need this. I'm removing it locally. I'm also adding a comment at the top of the fields inside Scope saying that they must be movable through memcpy.
WebKit Commit Bot
Comment 6
2016-03-17 17:34:42 PDT
Attachment 274344
[details]
did not pass style-queue: ERROR: Source/WTF/wtf/SmallPtrSet.h:113: Multi line control clauses should use braces. [whitespace/braces] [4] ERROR: Source/WTF/wtf/SmallPtrSet.h:243: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] Total errors found: 2 in 8 files If any of these errors are false positives, please file a bug against check-webkit-style.
Saam Barati
Comment 7
2016-03-17 17:37:52 PDT
Created
attachment 274345
[details]
patch
WebKit Commit Bot
Comment 8
2016-03-17 17:39:18 PDT
Attachment 274345
[details]
did not pass style-queue: ERROR: Source/WTF/wtf/SmallPtrSet.h:113: Multi line control clauses should use braces. [whitespace/braces] [4] ERROR: Source/WTF/wtf/SmallPtrSet.h:243: Weird number of spaces at line-start. Are you using a 4-space indent? [whitespace/indent] [3] Total errors found: 2 in 8 files If any of these errors are false positives, please file a bug against check-webkit-style.
Saam Barati
Comment 9
2016-03-17 17:42:15 PDT
Created
attachment 274346
[details]
patch
WebKit Commit Bot
Comment 10
2016-03-17 17:44:00 PDT
Attachment 274346
[details]
did not pass style-queue: ERROR: Source/WTF/wtf/SmallPtrSet.h:113: Multi line control clauses should use braces. [whitespace/braces] [4] Total errors found: 1 in 8 files If any of these errors are false positives, please file a bug against check-webkit-style.
Saam Barati
Comment 11
2016-03-17 17:44:41 PDT
Created
attachment 274347
[details]
patch
WebKit Commit Bot
Comment 12
2016-03-17 17:46:54 PDT
Attachment 274347
[details]
did not pass style-queue: ERROR: Source/WTF/wtf/SmallPtrSet.h:113: Multi line control clauses should use braces. [whitespace/braces] [4] Total errors found: 1 in 8 files If any of these errors are false positives, please file a bug against check-webkit-style.
Saam Barati
Comment 13
2016-03-17 19:11:50 PDT
landed in:
http://trac.webkit.org/changeset/198375
Sam Weinig
Comment 14
2016-03-17 20:03:20 PDT
Would there be value in trying to add this optimization (perhaps optionally using traits) to our HashMap/HashSet code? Presumably this optimization could be useful in other places, where they weren't necessarily storing pointers. Also, is the reason you don't support remove to avoid having a branch for a deleteValue sentinel?
Oliver Hunt
Comment 15
2016-03-17 23:33:05 PDT
Comment on
attachment 274347
[details]
patch I would rather have had the inline size be a template parameter (as we do for other data structures) - we could give a default capacity so the general behaviour wouldn't be impacted.
Geoffrey Garen
Comment 16
2016-03-18 11:56:19 PDT
Comment on
attachment 274347
[details]
patch Longer-term, it would be nice to have inline capacity as an option in WTF::HashSet and WTF::HashMap. Perhaps the optimizations you've added for never removing, linear scanning, and memcpy are fundamentally incompatible with those more flexible data structures. But maybe not.
Saam Barati
Comment 17
2016-03-20 12:58:06 PDT
(In reply to
comment #14
)
> Would there be value in trying to add this optimization (perhaps optionally > using traits) to our HashMap/HashSet code? Presumably this optimization > could be useful in other places, where they weren't necessarily storing > pointers. > > Also, is the reason you don't support remove to avoid having a branch for a > deleteValue sentinel?
I think it's worth experimenting with some inline capacity inside HashMap/HashSet. I'm sure there are places where this would really help out. Not supporting remove() does remove a branch, but it also simplifies some of the assumptions made in the code. It wouldn't be that difficult to add support for remove, but I'm hesitant to do it. I really want this data structure to be as simple as possible. I think one place where it might be worth adding some complexity is in supporting smart pointers. I don't think it'd be that difficult to do.
Saam Barati
Comment 18
2016-03-20 12:59:07 PDT
(In reply to
comment #15
)
> Comment on
attachment 274347
[details]
> patch > > I would rather have had the inline size be a template parameter (as we do > for other data structures) - we could give a default capacity so the general > behaviour wouldn't be impacted.
I think this is worth doing at some point. It seems like a good patch to do when we find code that needs it. LLVM's implementation does support inline capacity as a template parameter.
Saam Barati
Comment 19
2016-03-20 13:02:42 PDT
(In reply to
comment #16
)
> Comment on
attachment 274347
[details]
> patch > > Longer-term, it would be nice to have inline capacity as an option in > WTF::HashSet and WTF::HashMap. Perhaps the optimizations you've added for > never removing, linear scanning, and memcpy are fundamentally incompatible > with those more flexible data structures. But maybe not.
I'm not sure. I would have to familiarize myself more with the details of how HashMap/HashSet are implemented. I'm sure it would be possible to add inline capacity to HashMap/HashSet in some form, but maybe it wouldn't be exactly as it is implemented here. For example, HashMap/HashSet support remove, so when we're in small mode and we perform contains(.) we will have to traverse the entire inline array instead of just up to m_size.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug