WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED WONTFIX
165031
Remove unneeded additional level of short strings optimization in LiteralParser
https://bugs.webkit.org/show_bug.cgi?id=165031
Summary
Remove unneeded additional level of short strings optimization in LiteralParser
Darin Adler
Reported
2016-11-22 09:20:18 PST
Remove unneeded additional level of optimization in LiteralParser
Attachments
Patch
(5.81 KB, patch)
2016-11-22 09:40 PST
,
Darin Adler
no flags
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Darin Adler
Comment 1
2016-11-22 09:40:54 PST
Created
attachment 295338
[details]
Patch
Darin Adler
Comment 2
2016-11-22 09:42:36 PST
Yusuke, I would like to know your thoughts about this. Am I correct that this is not needed, or did I miss something?
Darin Adler
Comment 3
2016-11-22 10:30:21 PST
Comment on
attachment 295338
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=295338&action=review
> Source/JavaScriptCore/runtime/LiteralParser.cpp:133 > + if (length < 2 || characters[0] >= MaximumCachableCharacter)
I think length <= 1 would be easier to understand than length < 2.
> Source/JavaScriptCore/runtime/LiteralParser.h:198 > + static constexpr unsigned MaximumCachableCharacter = 128;
Just realized this name is not accurate. The maximum "cachable character" is 127, not 128.
Yusuke Suzuki
Comment 4
2016-11-22 13:19:34 PST
(In reply to
comment #2
)
> Yusuke, I would like to know your thoughts about this. Am I correct that > this is not needed, or did I miss something?
Agreed. Yeah, we already have the optimization path for empty & 1 length Identifiers in Identifier::add. So, these optimization seems duplicate. BTW, we have similar mechanism for JS parser. You can find it in ParserArena's makeIdentifier. While they need to hold all the identifiers in m_identifiers (to keep its lifetime), caching mechanism by m_recentIdentifiers is the same. Can you drop this thing too? And I think we need to take some performance numbers. Once JS parser change is also done, I recommend to run Octane's CodeLoad. It's parser heavy benchmark. And I also recommend to run kraken and its json benchmark. (But maybe, this benchmark does not contain empty string).
Yusuke Suzuki
Comment 5
2016-11-22 13:22:01 PST
BTW, String::empty is static function, so it will be converted to function calls. If it causes slow down, returning vm.propertyNames->emptyIdentifier in Identifier is one idea.
Darin Adler
Comment 6
2016-11-27 10:11:30 PST
(In reply to
comment #4
)
> BTW, we have similar mechanism for JS parser. You can find it in > ParserArena's makeIdentifier. While they need to hold all the identifiers in > m_identifiers (to keep its lifetime), caching mechanism by > m_recentIdentifiers is the same. > > Can you drop this thing too?
I think the situation is different in ParserArena; when we get something out of ParserArena::m_shortIdentifiers, we don't need to add it to ParserArena::m_identifiers again because we already know it’s in there. I suspect that optimization is worthwhile; avoids the possibility of needing to grow m_identifiers for example. But in LiteralParser, there is no such benefit. On the other
> And I think we need to take some performance numbers. Once JS parser change > is also done, I recommend to run Octane's CodeLoad. It's parser heavy > benchmark. > And I also recommend to run kraken and its json benchmark. (But maybe, this > benchmark does not contain empty string).
Good suggestions.
> BTW, String::empty is static function, so it will be converted to function calls.
I knew it was a static function, but I am really surprised it’s not inlined.
> If it causes slow down, returning vm.propertyNames->emptyIdentifier in Identifier is > one idea.
Agreed.
Darin Adler
Comment 7
2016-11-27 12:10:24 PST
Looks like the single character code path in SmallStrings also has a function call. So this patch is not quite right as-is.
Yusuke Suzuki
Comment 8
2016-11-27 21:36:21 PST
(In reply to
comment #6
)
> (In reply to
comment #4
) > > BTW, we have similar mechanism for JS parser. You can find it in > > ParserArena's makeIdentifier. While they need to hold all the identifiers in > > m_identifiers (to keep its lifetime), caching mechanism by > > m_recentIdentifiers is the same. > > > > Can you drop this thing too? > > I think the situation is different in ParserArena; when we get something out > of ParserArena::m_shortIdentifiers, we don't need to add it to > ParserArena::m_identifiers again because we already know it’s in there. I > suspect that optimization is worthwhile; avoids the possibility of needing > to grow m_identifiers for example. But in LiteralParser, there is no such > benefit.
Oh, right.
> > On the other > > > And I think we need to take some performance numbers. Once JS parser change > > is also done, I recommend to run Octane's CodeLoad. It's parser heavy > > benchmark. > > And I also recommend to run kraken and its json benchmark. (But maybe, this > > benchmark does not contain empty string). > > Good suggestions. > > > BTW, String::empty is static function, so it will be converted to function calls. > > I knew it was a static function, but I am really surprised it’s not inlined. >
I think this should be inlined. The way in my mind is, (1): defining `constexpr` StringImpl constructor (2): defining static StringImpl for empty string (3): returning the address of (2) in StringImpl::empty() I'll attempt to create the patch for this. In particular, (1) is nice. Once it is done, we can easily define static strings in C++.
> > If it causes slow down, returning vm.propertyNames->emptyIdentifier in Identifier is > > one idea. > > Agreed.
Darin Adler
Comment 9
2016-11-28 09:14:38 PST
I’ve found lots of non-inlined things that I thought were inlined. There is some work needed to make SmallStrings give inline access to the single character strings. Separately, I am confused by the many different empty strings, and particularly the issues when using empty strings on multiple threads.
Darin Adler
Comment 10
2017-12-09 15:49:42 PST
I’m not going to bother with this. At least not keeping a bug open about it.
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