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

Numerous Tokens Performance #13

Open
Cpecific opened this issue Dec 28, 2020 · 1 comment
Open

Numerous Tokens Performance #13

Cpecific opened this issue Dec 28, 2020 · 1 comment

Comments

@Cpecific
Copy link

Cpecific commented Dec 28, 2020

Performance on large files is atrocious.
You can look at code here https://github.com/Cpecific/twwh2_ancillary/blob/master/node_modules/tokenizr/lib/tokenizr.js
Mainly added Tokenizr._pendingPos. Switched from concatting and shifting arrays to simply iterating over them.
In my case it was an improvement from unknown amount of hours/days to barely a second. Probably issue crops up because of using transactions, but not sure, I wrote this code couple months back.
I would like to spend some time to improve it further, but sadly barely have time for such a side project.
Not sure if it is even the right way to do it, as I didn't try to understand all uses of library that much.
Probably have some bugs.

@rse
Copy link
Owner

rse commented Dec 28, 2020

Hmmm.... that's interesting. Sure, array operations might cost more than a simple integer operation, but I guess it mainly has to do in your case because of an excessive amount of backtracking with transactions and in this case the array operation costs accumulate dramatically. I'll check this in more detail when I find time again for the Tokenizr project.

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

2 participants