Performance: Whiskers Regexes Cache+Optimize#16736
Conversation
Reuse static optimized regex objects in Whiskers template validation and rendering. On the target via-IR benchmark this regex-only variant measured 1.0335s warm average versus the 1.0640s baseline.
|
First of all, thanks! Looks very neat, I hope we can merge this within a week or so. Scheduled the run on our benchmarking setup, https://github.com/argotorg/solc-bench/ I'll post the |
|
Running my own wider benchmark made the results better. Looking forward to yours.
|
|
OOoo that's a nice set! Might steal that :D Do you wanna make a PR to solc-bench adding these? Otherwise, I'll add them :) But you know, while I like stealing, I'd rather you gave them away 😆 |
|
It's my list from purplebench, available here: https://github.com/DanielVF/purplebench/tree/master/suite/contracts If you import them, you could probably rename the actual contract name in the code to be clearer. I tried to select a set of important contracts with high TLV / transactions across a couple different domains. I then ripped out the pragmas, and upgraded the code to run on the latest compiler versions. |
|
We should review and merge this asap :) |
OK, stealing it then 😆 😆 😆 |
|
Well, actually - this could've (should've?) gotten a changelog entry as user-visible performance improvement. |
Is there precedent for this? I wouldn't be against it to be honest, could even write a blog post after we merge more in. |
|
BTW, I had a similar, but shittier one at one point in my not very long Solidity life 😆 |
Yep there is! Check the changelog for recent entries. There are a couple in there. |
|
We can add it as a follow-up, perhaps as part of merging #16741 ? |
|
Yes, I'll add to 16741. |
Description
3% compile time improvement for
--via-ircomplilation+optimization and large solidity files, over 100 runs for this change and a baseline.Adding the 'std::regex_constants::optimize' flag increases the compile time for the regex, but reduces the run time each time it is used. Adding const to the regex creation, means that we only pay this penalty once, but benefit from it each run.
(The const change alone makes a small speedup, while optimize without the const makes a slowdown, since the extra computation for optimization isn't worth it unless the regex object is used multiple times.)
Checklist
Al Disclosure