Skip to content

metricwriter: compile regular expressions only on first use#2641

Merged
crazy-max merged 1 commit into
docker:masterfrom
jsternberg:metricwriter-lazy-regexp
Aug 7, 2024
Merged

metricwriter: compile regular expressions only on first use#2641
crazy-max merged 1 commit into
docker:masterfrom
jsternberg:metricwriter-lazy-regexp

Conversation

@jsternberg

@jsternberg jsternberg commented Aug 5, 2024

Copy link
Copy Markdown
Collaborator

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>
@jsternberg
jsternberg force-pushed the metricwriter-lazy-regexp branch from b93fdd2 to 2810f20 Compare August 5, 2024 15:23
@crazy-max crazy-max added this to the v0.17.0 milestone Aug 6, 2024
@crazy-max

Copy link
Copy Markdown
Member

I assume this fixes #2596?

@jsternberg

Copy link
Copy Markdown
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
@jsternberg
jsternberg deleted the metricwriter-lazy-regexp branch August 8, 2024 14:18
@tonistiigi

Copy link
Copy Markdown
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