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

Tx: High Cost of super() call in Constructors / Inheritance #3694

Open
holgerd77 opened this issue Sep 22, 2024 · 2 comments · May be fixed by #3733
Open

Tx: High Cost of super() call in Constructors / Inheritance #3694

holgerd77 opened this issue Sep 22, 2024 · 2 comments · May be fixed by #3733

Comments

@holgerd77
Copy link
Member

Related: #3484

Today I looked into tx instantiation (thinking from client perspective where we consecutively instantiate thousands of txs), and results were quite suprising:

grafik grafik

So these are times measuring the costs of the steps along tx construction (in total tx instantiation is quite noticeable, ~230ms for 10.000 txs, this comes together quickly). Notice the t1 step: this is for the super() call. I first thought: oh, something expensive in super(), but: no. The s* are actually the super measurements. This doesn't sum up. Turns out the costly thing is the super() call itself. I stumbled upon this article on Netflix Tech Blog about general performance downsides of JS inheritance / super() calls.

I think this information is likely primarily relevant in the context of the tx refactor, I therefore assigned @jochem-brouwer to this issue, more to take notice than to directly act upon. This might be another strong argument to generally get rid of the BaseTransaction (@jochem-brouwer, I think you already mentioned something like this? I also thought about this couple of times).

@jochem-brouwer
Copy link
Member

jochem-brouwer commented Sep 22, 2024

Hi Holger, thanks for writing this down. I was not aware that super methods have such a performance impact!

The goal of the tx-refactor from my side actually has two goals which I want to tackle at once:

  1. Remove redundant code
  2. Remove BaseTransaction

Might look like two separate tasks, but I did some quick-and-dirty experimenting and I think these two work well together. I want to open a proof-of-concept PR this week to show the general idea, it mainly consists expanding the Capabilities idea which we already have in Tx to expand this to other redundant code, and to remove BaseTransaction along altogether!

@holgerd77
Copy link
Member Author

Sounds great! 🙂

@jochem-brouwer jochem-brouwer linked a pull request Oct 9, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants