aws / event-ruler

Event Ruler is a Java library that allows matching many thousands of Events per second to any number of expressive and sophisticated rules.
Apache License 2.0
566 stars 63 forks source link

Performance improvements on the addPattern code path. Avoiding lots of unnecessary Set creations. #104

Closed jonessha closed 1 year ago

jonessha commented 1 year ago

Description of changes:

Main strategy was turning SingleByteTransition into an Iterable of itself, and then changing many methods that returned Sets to return Iterables, so that in the n=1 case, we can return a SingleByteTransition instead of a single-element set and avoid the set creation. Also, revised updateTransition in ByteMap to work on the same TreeMap instead of creating a replacement.

In my testing, this gives up to a 25% reduction in GC activity, and a 50% reduction in machine creation latency at p99.9.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

baldawar commented 1 year ago

is the performance high enough to update the number within the readme ?

jonessha commented 1 year ago

is the performance high enough to update the number within the readme ?

The performance improvement is just during machine creation, but not during matching. I don't think we have machine creation latency numbers in the README?

baldawar commented 1 year ago

oh you're right. Odd that we don't have a benchmark for this. Feels like a miss. Worth an issue?

jonessha commented 1 year ago

oh you're right. Odd that we don't have a benchmark for this. Feels like a miss. Worth an issue?

Sure. https://github.com/aws/event-ruler/issues/105