-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: stop compiling static regex in hot path, compile once globally
Previously, these static regexs were being compiled each time the function is called. The regexs are static, so there's no need to re-compile them everytime; instead, compile them once globally per package, and then re-use them when needed. This reduces the number of allocations made over the life span of the program; resulting in less active memory use in general, as well as less garbage collection. Local profiling with parca and a shimmed in pprof web server show me approx ~20% less in use memory, going from `~8-10MB` -> `~6-8MB` after changes. Signed-off-by: TJ Hoplock <t.hoplock@gmail.com>
- Loading branch information
Showing
4 changed files
with
18 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters