kamon-io / kanela

The Kamon Instrumentation Agent
Apache License 2.0
68 stars 22 forks source link

Optimize `within` pattern matching for Kanela modules [WIP] #141

Open melezov opened 2 years ago

melezov commented 2 years ago

ByteBuddy's StringMatcher uses String.matches which performs about 10x slower than caching a Pattern inside a custom PatternMatcher

Uglify the test / reference pattern examples to more closely match the required patterns

This change speeds up the boot of our production by 5-10% (times in ms) image

Context: Testing the Kamon Bundle in our SaaS and probing how to reduce the now prolonged boot times. The matches method of StringMatcher gets invoked about a million times during the boot (can provide logs) and seems to be a hotspot worth looking into.

melezov commented 2 years ago

At the end of the day, we'll probably manually add modules we're interested in, instead of using the bundle.

melezov commented 2 years ago

Send a shout if you need this broken into multiple PRs. Tests should be good now.

dpsoft commented 2 years ago

@melezov thanks for this PR, I'll take a look ASAP.