Bug 158506

Summary: CachedScript should avoid recomputing its hash multiple times.
Product: WebKit Reporter: Andreas Kling <kling>
Component: WebCore JavaScriptAssignee: Andreas Kling <kling>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, commit-queue, ggaren, japhet, kling, sbarati
Priority: P2 Keywords: Performance
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
sbarati: review+
Patch for landing none

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 :|