Skip to content

Conversation

@akiselev98
Copy link
Contributor

Profiling showed that a relatively high percentage of CPU time and memory allocations are coming from decorator parsing. This makes sense, since this parsing is applied to every unified log line which goes through gctoolkit.

To speed things up, we:

  • Fold the tags regex into the broader decorator regex, avoiding the need for a second matcher, and removing the need for an expensive negative lookbehind in the tag pattern
  • Add a start of line anchor to the decorator regex
  • Defer sanitization of tags until getTags() is called for the first time

To reduce unnecessary memory allocations, match groups are retrieved once and stored in an array.

In testing, these optimizations cut the running time of gctoolkit roughly in half.

Profiling showed that a relatively high percentage of CPU time and memory
allocations are coming from decorator parsing. This makes sense, since
this parsing is applied to every unified log line which goes through
gctoolkit.

To speed things up, we:
- Fold the tags regex into the broader decorator regex, avoiding the
  need for a second matcher, and removing the need for an expensive
  negative lookbehind in the tag pattern
- Add a start of line anchor to the decorator regex
- Defer sanitization of tags until getTags() is called for the first time

To reduce unnecessary memory allocations, match groups are retrieved
once and stored in an array.

In testing, these optimizations cut the running time of gctoolkit
roughly in half.
karianna
karianna previously approved these changes Oct 19, 2025
@obourgain
Copy link

this is indeed faster, about twice faster for my use case too.

@karianna
Copy link
Member

@johnoliver can you review as well

johnoliver
johnoliver previously approved these changes Oct 29, 2025
karianna
karianna previously approved these changes Oct 29, 2025
@karianna
Copy link
Member

@akiselev98 - Can you resolve the one item? Then we can merge :-)

@akiselev98 akiselev98 dismissed stale reviews from karianna and johnoliver via ca74dfd October 30, 2025 13:32
@karianna karianna merged commit 50464ae into microsoft:main Nov 3, 2025
8 checks passed
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.

4 participants