Skip to content

Big performance drop due to switching TS output from ES5 to ES6 #3648

Closed
@IvanGoncharov

Description

@IvanGoncharov

I investigated the performance drop between v15 and v16 and it was caused by switching transpilation target from es5 to es6.
It's easy to reproduce with the following diff:

diff --git a/tsconfig.json b/tsconfig.json
index edb522f1..299b9309 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -7,7 +7,7 @@
   ],
   "compilerOptions": {
     "lib": ["es2020"],
-    "target": "es2020",
+    "target": "es5",
     "module": "commonjs",
     "moduleResolution": "node",
     "strict": true,

Note: some of the functionality stops working due to an error in this file (we can't extend Map in es5):
https://github.com/graphql/graphql-js/blob/main/src/jsutils/AccumulatorMap.ts

But even benchmarks that are working showing pretty big performance difference:
local is ES5 and HEAD is ES2020

image

I don't think we need to switch back to ES5 since it has its own drawbacks but instead, we just need to figure out what is slowing us and implement that code changes manually in our code base.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions