-
-
Notifications
You must be signed in to change notification settings - Fork 90
[WIP] Cache runes in chars mode #252
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
base: master
Are you sure you want to change the base?
Conversation
|
using caching for the other functions (e.g. an alternative in this case is to convert the needle to runes and search for it in the haystack slice of runes, but i'm not sure if that has subtle edge cases we may care about (e.g. string normalisation? does on the other hand even with just implementing this optimisation for thoughts? |
|
@benhoyt gentle bump, no rush but i'd love to know how you think this looks for a prototype |
|
Hi @triallax, I'm not opposed to the approach itself. However, I guess the main thing I'm worried about is that it significantly slows down normal (bytes-mode) performance, due I suppose to all the additional allocations from the We could try to have a switch in the interpreter which avoids the allocation if in bytes mode. The wiring for that might be annoying, but at least we could test performance. Even then I'd want to make sure the if/else in the hot path didn't slow bytes-mode down much -- GoAWK's been fairly focussed on performance, and I'd hate to regress much. In any case, it'd be good if you could show some performance numbers, and we could come up with a way to avoid the extra |
|
@triallax Any thoughts on my comment above? |
hi Ben, apologies I forgot this PR was a thing :D
I suspect branch predictors would make this essentially a non-issue (given that per goawk execution, only one branch of the if else will ever be taken) but we'll see for sure once i do some benchmarks |
|
(sorry for the delay, been a lil busy, i promise i'll get around to this very soon) |
WIP implementation of my proposal in #35 (comment)
unsophisticated and needs further testing and benchmarking, but already quite promising: running
gron.awkon a big JSON file in chars mode goes from taking 12(!) minutes to 4 seconds on my laptop with this branch in its current form.