[Webkit-unassigned] [Bug 117488] New: Consider atomicizing inline scripts before execution

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Jun 10 22:10:00 PDT 2013


https://bugs.webkit.org/show_bug.cgi?id=117488

           Summary: Consider atomicizing inline scripts before execution
           Product: WebKit
           Version: 528+ (Nightly build)
          Platform: Unspecified
        OS/Version: Unspecified
            Status: NEW
          Keywords: BlinkMergeCandidate
          Severity: Normal
          Priority: P2
         Component: Text
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: rniwa at webkit.org
                CC: darin at apple.com, barraclough at apple.com,
                    benjamin at webkit.org, fpizlo at apple.com


https://chromium.googlesource.com/chromium/blink/+/d14b5c9da043f4569a0fa2058a0c59e1e984d006
alloon-juice.com should use 85 kB less memory

Browsing around the web with STRING_STATS, I noticed we commonly end up with
duplicated scripts String. Studying the issue more carefully, I determined that
these scripts were inline scripts that appeared multiple times (e.g., in
different iframes).

This CL teaches Blink to atomize inline scripts immediately before executing
them. If an inline script appears in multiple documents, they'll end up sharing
the same underlying string storage.

An alternative is to atomize the string as we're constructing the DOM, but that
can work poorly if there is a network packet boundary in the middle of (large)
inline script blocks. Instead, we want to wait until we're done parsing the
script element. Doing the atomization immediately before execution also lets us
piggyback on the logic that checks whether the script element has a single
child Text node, which is exactly the case in which atomization is likely to be
useful.

I used ballon-juice.com as a test bed for studying this issue because it is a
fairly typical blog-based web site. This CL dropped the memory wasted by
duplicate strings from 94,809 kB to 10,280 kB, a savings of 85 kB. Here is an
example string before and after this CL:

== Before ==

2 copies (ok) of length 52790 /* <![CDATA[ */?if(!((window._atc||{}).ver)){var _atd="www.addth...

== After ==

1 copies (ok) of length 52790 /* <![CDATA[ */?if(!((window._atc||{}).ver)){var _atd="www.addth...

We should consider the same optimization for inline style elements as well if
we see them wasting memory in the same way.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list