Bug 158506 - CachedScript should avoid recomputing its hash multiple times.
Summary: CachedScript should avoid recomputing its hash multiple times.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Andreas Kling
URL:
Keywords: Performance
Depends on:
Blocks:
 
Reported: 2016-06-07 17:58 PDT by Andreas Kling
Modified: 2016-06-08 18:41 PDT (History)
6 users (show)

See Also:


Attachments
Patch (1.63 KB, patch)
2016-06-07 18:00 PDT, Andreas Kling
sbarati: review+
Details | Formatted Diff | Diff
Patch for landing (1.61 KB, patch)
2016-06-07 18:21 PDT, Andreas Kling
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Kling 2016-06-07 17:58:00 PDT
CachedScript::script() can skip string hashing if we've already decoded the script before and saved the hash (in m_scriptHash.)
This should help JSBench quite a bit.
Comment 1 Andreas Kling 2016-06-07 18:00:15 PDT
Created attachment 280753 [details]
Patch
Comment 2 Saam Barati 2016-06-07 18:12:57 PDT
Comment on attachment 280753 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=280753&action=review

R=me

> Source/WebCore/loader/cache/CachedScript.cpp:96
> +        // If we've decoded this once before, we already have the hash in m_scriptHash.

We could also just assert this
Like:
ASSERT(!m_scriptHash || m_scriptHash == m_script.impl()->hash())
Comment 3 Saam Barati 2016-06-07 18:14:29 PDT
Comment on attachment 280753 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=280753&action=review

>> Source/WebCore/loader/cache/CachedScript.cpp:96
>> +        // If we've decoded this once before, we already have the hash in m_scriptHash.
> 
> We could also just assert this
> Like:
> ASSERT(!m_scriptHash || m_scriptHash == m_script.impl()->hash())

(If we start with m_scriptHash at zero)
Comment 4 Andreas Kling 2016-06-07 18:21:37 PDT
Created attachment 280757 [details]
Patch for landing
Comment 5 WebKit Commit Bot 2016-06-07 18:52:17 PDT
Comment on attachment 280757 [details]
Patch for landing

Clearing flags on attachment: 280757

Committed r201784: <http://trac.webkit.org/changeset/201784>
Comment 6 WebKit Commit Bot 2016-06-07 18:52:21 PDT
All reviewed patches have been landed.  Closing bug.
Comment 7 Geoffrey Garen 2016-06-08 10:29:01 PDT
Comment on attachment 280757 [details]
Patch for landing

View in context: https://bugs.webkit.org/attachment.cgi?id=280757&action=review

> Source/WebCore/ChangeLog:12
> +        This takes total time spent in StringImpl::hashSlowCase() from 1600ms to 77ms on my MBP.

huehuehue
Comment 8 Andreas Kling 2016-06-08 18:41:17 PDT
(In reply to comment #7)
> Comment on attachment 280757 [details]
> Patch for landing
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=280757&action=review
> 
> > Source/WebCore/ChangeLog:12
> > +        This takes total time spent in StringImpl::hashSlowCase() from 1600ms to 77ms on my MBP.
> 
> huehuehue

Unfortunately it looks like this silliness was taking place outside of JSBench measurement signposts :|