-
-
Notifications
You must be signed in to change notification settings - Fork 263
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
JS thread overloads when pasting numerous times with RegEx mask #882
Comments
hi @blake-discover, Well, by design
general recommendations:
From my side I will also check performance in general. |
Hey @blake-discover it looks like this is just the result of a very slow moving regex being asked to do a lot at once. If you pop open Chrome DevTools' performance view, we can see that what's blocking is literally just a RegExp call evaluating, and taking some milliseconds to finish when faced with strings like "[email protected]@[email protected]". But the time to evaluate it grows with its length, and so rapid pasting just saturates the thread. I wish I knew enough regex-fu to tell you what about that is greedy/slow/whatever, and if it could be improved. I have good news, though: the answer is debouncing! Just wait some small amount of time after a user finishes text entry to run and you should be fine. You can actually simulate this on your JSFiddle. Wait a little bit in between pasting and everything's hunky dory. I imagine that's how tools like https://regexr.com/ can handle this just fine. All the same, @uNmAnNeR I would posit that this is firmly not slowness from this library, and can probably be closed - although tracking perf sounds like a good idea too! |
Describe the bug
I'm not sure if this is in scope of this project or not, but I'm experiencing performance issues on paste event. I found when either pasting numerous times or typing exceptionally fast, the JS thread locks up. I believe there is an iterator somewhere that is slowing down the formatting.
To Reproduce
Expected behavior
JS thread should not lock up.
Environment:
System:
OS: macOS 13.4
CPU: (10) arm64 Apple M1 Pro
Memory: 868.27 MB / 32.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 16.19.1 - ~/.nvm/versions/node/v16.19.1/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v16.19.1/bin/yarn
npm: 8.19.3 - ~/.nvm/versions/node/v16.19.1/bin/npm
Browsers:
Chrome: 114.0.5735.133
Edge: 113.0.1774.57
Safari: 16.5
Additional context
n/a
The text was updated successfully, but these errors were encountered: