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

Compile regex pattern for MetricFilter only once #2637

Merged
merged 1 commit into from Aug 9, 2016

Conversation

Projects
None yet
2 participants
@mikkolehtisalo
Contributor

mikkolehtisalo commented Aug 8, 2016

Description

Noticed a static regex getting compiled 60 times per second on my system. Modified implementation so that it gets compiled only once. Also moved the anonymous class outside run() so that further tests are easier to implement.

Motivation and Context

This tiny change frees whopping ~1 millisecond of CPU time every second for actual message processing duties.

How Has This Been Tested?

Added a unit test for positive test case.

Screenshots (if appropriate):

hello-sir

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the code style of this project.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@joschi joschi self-assigned this Aug 9, 2016

@joschi joschi added this to the 2.1.0 milestone Aug 9, 2016

@joschi joschi added the improvement label Aug 9, 2016

@joschi

This comment has been minimized.

Contributor

joschi commented Aug 9, 2016

LGTM. 👍

Thanks, Mikko!

@joschi joschi merged commit 3d06f69 into Graylog2:master Aug 9, 2016

3 checks passed

ci-server-integration Jenkins build graylog2-server-integration-pr 1228 has succeeded
Details
ci-web-linter Jenkins build graylog-pr-linter-check 711 has succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@joschi

This comment has been minimized.

Contributor

joschi commented Aug 9, 2016

We might even save some cycles by simply using String#startsWith(String) and String#endsWith(String), but that's no concern right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment