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
Improve how reference regexps are built #3566
Improve how reference regexps are built #3566
Conversation
Previous implementation was doing a lot of string -> regexp -> string conversions Signed-off-by: Paul Cacheux <paul.cacheux@datadoghq.com>
This comment has been minimized.
This comment has been minimized.
Looking at the code, it seems like it would be more efficient, but would you also mind providing a couple of benchmarks, so we can quantify the improvement? |
Signed-off-by: Paul Cacheux <paul.cacheux@datadoghq.com>
Here is a repo with benchmarks around this PR https://github.com/paulcacheux/distrib-re-benchmark. Since it's benchmarking an init function it's a bit hacky but it works. |
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.
Nice! LGTM.
I really appreciate this, thank you! For posterity, this is the output from my machine: Previous
This PR
|
LGTM 🚀 |
Improve the code such that a given raw regex string is compiled only once. Before: init 1341880 bytes, 11453 allocs After: init 485600 bytes, 4501 allocs Copied-from: distribution/distribution/pull/3566 Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
Improve the code such that a given raw regex string is compiled only once. Before: init 1341880 bytes, 11453 allocs After: init 485600 bytes, 4501 allocs Copied-from: distribution/distribution/pull/3566 Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
This PR reduces the amount of
string -> *regexp.Regexp -> string
in reference Regexps. This conversion (especially the compilation is quite expensive both in memory and CPU usage.This PR tries to be as minimal as possible by ensuring that the same regexps are exported (even those that are not really exported but just used in the same package) but I would be happy to change it to anything else if bigger changes are desired.
Signed-off-by: Paul Cacheux paul.cacheux@datadoghq.com