Bug 91531

Summary: Web Inspector: intern strings when processing timeline records
Product: WebKit Reporter: Andrey Kosyakov <caseq>
Component: Web Inspector (Deprecated)Assignee: Andrey Kosyakov <caseq>
Status: RESOLVED FIXED    
Severity: Normal CC: apavlov, bweinstein, joepeck, keishi, loislo, pfeldman, pmuellr, rik, timothy, yurys
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch
none
Patch pfeldman: review+

Description Andrey Kosyakov 2012-07-17 12:01:46 PDT
This adds StringPool class and uses it to intern all strings occurring in Timeline records. This cuts heap size from 117M to 50M when processing a 97M timeline log.
Comment 1 Andrey Kosyakov 2012-07-17 12:13:52 PDT
Created attachment 152803 [details]
Patch
Comment 2 Pavel Feldman 2012-07-17 13:05:28 PDT
Comment on attachment 152803 [details]
Patch

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

> Source/WebCore/inspector/front-end/utilities.js:729
> +    deepIntern: function(obj)

internObject?

> Source/WebCore/inspector/front-end/utilities.js:737
> +                this.deepIntern(obj[field]);

Do you want to introduce a re-entrance guard here to say support up to 100 levels? Stack overflow is sometimes hard to debug.
Comment 3 Andrey Adaikin 2012-07-18 00:29:39 PDT
Comment on attachment 152803 [details]
Patch

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

> Source/WebCore/inspector/front-end/utilities.js:711
> +    intern: function(string)

what if string is equal to "__proto__" or "constructor" or "toString" or etc. ?
maybe add (this._strings.__proto__ = null) to the constructor and reset() methods?

>> Source/WebCore/inspector/front-end/utilities.js:729
>> +    deepIntern: function(obj)
> 
> internObject?

a test case: 

var obj = {};
obj.foo = obj;
pool.deepIntern(obj);
Comment 4 Andrey Kosyakov 2012-07-18 06:09:18 PDT
Created attachment 153002 [details]
Patch
Comment 5 Pavel Feldman 2012-07-18 06:23:58 PDT
Comment on attachment 153002 [details]
Patch

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

> Source/WebCore/inspector/front-end/TimelinePresentationModel.js:635
> +        if (!this._details)

Is this a part of a different change?

> Source/WebCore/inspector/front-end/utilities.js:729
> +        if (string === "__proto__")

What does this mean?

> Source/WebCore/inspector/front-end/utilities.js:741
> +        this._strings = { __proto__: null };

Object.create(null)
Comment 6 Andrey Kosyakov 2012-07-18 06:46:43 PDT
Committed r122964: <http://trac.webkit.org/changeset/122964>