Skip to content
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

metricwriter: compile regular expressions only on first use #2641

Merged
merged 1 commit into from
Aug 7, 2024

Conversation

jsternberg
Copy link
Collaborator

@jsternberg jsternberg commented Aug 5, 2024

Compile the regular expressions only on first use rather than implicitly as part of the init() function of the package. This prevents taking a speed hit on the initialization of the package regardless if this type is used and moves it to the time when a regular expression is first used.

Fixes #2596.

@jsternberg jsternberg requested a review from daghack August 5, 2024 15:23
Compile the regular expressions only on first use rather than implicitly
as part of the `init()` function of the package. This prevents taking a
speed hit on the initialization of the package regardless if this type
is used and moves it to the time when a regular expression is first
used.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
@crazy-max crazy-max added this to the v0.17.0 milestone Aug 6, 2024
@crazy-max
Copy link
Member

I assume this fixes #2596?

@jsternberg
Copy link
Collaborator Author

Yes. I've updated the PR description to reference that issue.

@crazy-max crazy-max merged commit 238a3e0 into docker:master Aug 7, 2024
106 checks passed
@jsternberg jsternberg deleted the metricwriter-lazy-regexp branch August 8, 2024 14:18
@tonistiigi
Copy link
Member

The init side of this was handled but this part was not

For the matchers, it looks like all the regexp always try to match against all of the vertex records coming in progress. This should only need to happen once per vertex. If vertex is type=exec it can not be type=source at the same time and does not need to be repeatedly rechecked. If a type for a specific digest has already been found, it does not need to be rechecked again when new logs are arriving.

It's not a high priority to update this but I guess we should leave the issue open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

metrics regexp usage for progress can be optimized
3 participants