Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

persistent-merkle-tree: Performance issue with typescript 4.4.2 #187

Open
twoeths opened this issue Sep 8, 2021 · 0 comments
Open

persistent-merkle-tree: Performance issue with typescript 4.4.2 #187

twoeths opened this issue Sep 8, 2021 · 0 comments

Comments

@twoeths
Copy link
Contributor

twoeths commented Sep 8, 2021

With typescript 4.4.2, the node.ts is compiled to:

export abstract class Node implements HashObject {
  // this is to save an extra variable to check if a node has a root or not
  h0 = null as unknown as number;
  h1 = 0;
  h2 = 0;
  h3 = 0;
  h4 = 0;
  h5 = 0;
  h6 = 0;
  h7 = 0;

  abstract root: Uint8Array;
  abstract rootHashObject: HashObject;
  abstract left: Node;
  abstract right: Node;

  applyHash(root: HashObject): void {

this makes the performance test runs >10x slower as below
Screen Shot 2021-09-08 at 13 44 50

this is the profile with typescript 4.4.2
0908_monorepo.cpuprofile.zip

note the instance_members_initializer time, we don't have that with current version 4.2.3 which compiles node.ts to

class Node {
    constructor() {
        // this is to save an extra variable to check if a node has a root or not
        this.h0 = null;
        this.h1 = 0;
        this.h2 = 0;
        this.h3 = 0;
        this.h4 = 0;
        this.h5 = 0;
        this.h6 = 0;
        this.h7 = 0;
    }
    applyHash(root) {
        this.h0 = root.h0;
        this.h1 = root.h1;
        this.h2 = root.h2;
        this.h3 = root.h3;
        this.h4 = root.h4;
        this.h5 = root.h5;
        this.h6 = root.h6;
        this.h7 = root.h7;
    }
}

Screen Shot 2021-09-08 at 13 43 49

the profile with typescript 4.2.3
0908_separate_repo_ssz.cpuprofile.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant