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

generator support: eliminated performance sink in 'node-processor', solves #1293 #1294

Merged
merged 1 commit into from
Nov 21, 2023

Conversation

sailingKieler
Copy link
Contributor

  • added content length tracking to avoid repeated string concatenation under way

…olves #1293

* added content length tracking to avoid repeated string concatenation under way
@sailingKieler sailingKieler requested a review from msujew November 17, 2023 09:03
@@ -35,6 +36,10 @@ class Context {
return this.lines.map(e => e.join('')).join('');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That why I prefer to have a get or compute in names to make it clear there are things happening. Where this.content.length looks like a simple field access.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. 💯

Copy link
Contributor

@goto40 goto40 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work @sailingKieler !!

The patch fixes the performance effect:

Timings with my example now:

nb lines time in sec to produce input time for toString
3'200'000 0.7 2.7
1'600'000 0.3 1.25
800'000 0.15 0.7
400'000 0.1 0.4

This is much better than before:

nb lines time for toString
8'000 4.0
16'000 16.0

@goto40
Copy link
Contributor

goto40 commented Nov 18, 2023

I can also confirm that the output is identical for the example sketched in #1292:

wc -l ~/out_old.txt 
16449 ~/out_old.txt

wc -l ~/out_new.txt 
16449 ~/out_new.txt

diff ~/out_old.txt ~/out_new.txt 
16447,16448c16447,16448
< time to generate text:  0.004 sec
< time to convert text:  16.945 sec
---
> time to generate text:  0.006 sec
> time to convert text:  0.037 sec

Copy link
Member

@msujew msujew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me as well 👍

@sailingKieler sailingKieler merged commit b16bc7f into main Nov 21, 2023
3 checks passed
@sailingKieler sailingKieler deleted the cs/genPerformanceFix branch November 21, 2023 12:46
@spoenemann spoenemann added this to the v3.0.0 milestone Jun 17, 2024
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

Successfully merging this pull request may close these issues.

5 participants