-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
types/Coin: compile and reuse Regexps to reduce massive RAM+CPU burn #8001
Conversation
…7989) From: #7989 Closes: #7986 Co-authored-by: Federico Kunze <[email protected]> Co-authored-by: Alessio Treglia <[email protected]>
Codecov Report
@@ Coverage Diff @@
## launchpad/backports #8001 +/- ##
====================================================
Coverage 50.29% 50.30%
====================================================
Files 338 338
Lines 17570 17572 +2
====================================================
+ Hits 8837 8839 +2
Misses 7940 7940
Partials 793 793
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @alessio for working this, LGTM, but deferring to the release managers and also to others.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch!
Co-authored-by: Alessio Treglia <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the previous change that this modifies was not part of a tagged release, and the default usage remains the same, I see no issues with this.
Ack
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. @odeke-em nice example of profiling 👍🏻
This patch brings a client code breaking change. As such it requires a Stable Release Exception to be granted by the Stable Release Managers. @clevinson @ethanfrey
From: #7989
Closes: #7986
Co-authored-by: Federico Kunze [email protected]
Co-authored-by: Alessio Treglia [email protected]
Impact
The changes introduced in #7450 to support denoms custom validation
caused a significance performance hit due to the use of closures
instead of compiled regular expressions. As the reporter described in #7986,
this represents a security threat since many ParseCoin invocations made
concurrently could cause the client application to run out of RAM.
Test Case
The bug becomes visible by invoking ParseCoin concurrently 1000 times.
A benchmark test case is included in this PR.
Regression Potential
Regressions could manifest if the
CoinDenomRegex
was left publicly exposedas any modification to it by the client would not trigger the recompilation of the
regular expressions that depend on it. The original patch addresses potential
regressions by replacing
CoinDenomRegex
with the accessorSetCoinDenomRegex()
in the the
types
package public interface.Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerCodecov Report
in the comment section below once CI passes