[Webkit-unassigned] [Bug 212962] New: 4x slow execution slowdown when comparing the same codebase targeting ES2015 vs. ES5

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Jun 9 00:02:28 PDT 2020


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

            Bug ID: 212962
           Summary: 4x slow execution slowdown when comparing the same
                    codebase targeting ES2015 vs. ES5
           Product: WebKit
           Version: Safari Technology Preview
          Hardware: Macintosh
                OS: macOS 10.15
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: JavaScriptCore
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: mihaip at chromium.org

Created attachment 401421

  --> https://bugs.webkit.org/attachment.cgi?id=401421&action=review

ES2015 Time Profile Instruments output

We have have recently begun evaluating directly shipping ES2015 code in our application, instead of down-compiling it down to ES5. We have observed a significant performance regression when doing this in Safari.

Here is a somewhat reduced test case, that displays the execution time of the critical part our application (the time to load/render a document):
ES5 version: http://persistent.info/webkit/test-cases/es2015-slowness/?es5 - takes around 80ms
ES2015 version: http://persistent.info/webkit/test-cases/es2015-slowness/?es2015 - takes around 312ms

This has been observed in both Safari 13.1.1 and Safari Technology Preview 107 on macOS 10.15.5

A timeline recording shows significant time spent in the root "(program)" part of the script, which does not shed much light. 

We thus also ran the Web Content process under Instruments, and compared the top functions for the ES5 and ES2015 versions. The latter seemed to spend a lot of time in JSC::BytecodeGenerator::getVariablesUnderTDZ() and creating/populating hash tables that back  JSC::CompactVariableEnvironment (see attached es2015.trace file).

Given this clue, we generated a variant of the ES2015 output where all `let`s and `const`s were replaced with `var`s, and that yielded better results, though still not as fast as the ES5 version:

http://persistent.info/webkit/test-cases/es2015-slowness/?es2015-var - takes around 155ms

In case it helps, the original code is in TypeScript (using ES207 features including async/await). The TypeScript compiler handles the down-leveling to ES2015 or ES5. Rollup is then used as a bundler, it generates the IIFE that the entire script is wrapped in. I'm happy to try to generate an even smaller benchmark if it proves helpful.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20200609/e07f968e/attachment.htm>


More information about the webkit-unassigned mailing list