I have a rule that looks for 2 consecutive events for the same entity. To stress test it, I inserted 10K consecutive events. I'm calling fireAllRules() after each event is inserted. I'm printing out timestamps after every 100 events. I'm noticing that insertions/evaluations are increasingly slower as events are added. Here's the rule :
rule "Consecutive events"
when
$latest : Event($id : id) // newest event
not Event(id == $id, this after $latest) // no events after the newest
$previous : Event(id == $id, this before $latest) // event before the newest
not Event(id == $id, this before $latest, this after $previous) // no events between $latest and $previous
then
//System.out.println($latest.toString());
end
It is my understanding that the above rule should only match the latest 2 events and automatic memory management should remove older events. If so, why are insertions progressively slower? Interestingly, ksession.getObjects() returns all the events inserted and not just the latest 2 events. Is my understanding of the rule incorrect? Does the rule somehow force all events to stay in memory? I'm using v6.0.1.Final.