Re: Non-linearity of GroupBy

41 views
Skip to first unread message
Message has been deleted
Message has been deleted

Larry LeBron

unread,
Jul 15, 2019, 2:04:41 PM7/15/19
to NRules Users
Have you tried subscribing to the LHS clause evaluated diagnostic action and counting/analyzing how many clauses get evaluated when you do your fact insert to see if it's somehow growing non-linearly?

Larry LeBron

unread,
Jul 15, 2019, 3:18:09 PM7/15/19
to NRules Users
Another possibility is that your performance is suffering from groupby using the IEnumerable extension accidentally as seen here. https://stackoverflow.com/questions/36405274/linq-group-by-property-performance

Or that groupby itself grows non linearly if it's an nlogn implementation. You could test by counting the number of calls to access your groupby property for the two datasets.

Message has been deleted

Larry LeBron

unread,
Jul 15, 2019, 4:56:06 PM7/15/19
to NRules Users
To count the number of LHS clauses that are evaluated, you can subscribe like this:


void CreateSession()
{
ISession session = = sessionFactory.CreateSession();
session.Events.LhsExpressionEvaluatedEvent += DebugOnLHSExpressionEvaluated;
}

void DebugOnLHSExpressionEvaluated(object sender, LhsExpressionEventArgs e)
{
// count or use event args here - this will be called each time an LHS clause is evaluated
}

It's a relatively new event added to ISession, so you may need to update your version of NRules. For starters you can add a simple counter that you increment each time this action is invoked, to see how the number of clause evaluations is growing as you add more facts.

As for evaluating the performance of groupby itself I was just suggesting that you try incrementing a counter in the accessor for your pw.IssuerId.Value to see how many times its called during the insert of your facts. I have a suspicion that groupby may be called a logarithmically increasing number of times as your collection grows, but not sure. You'd need to track it to see.

Hope that all makes sense!
Message has been deleted

Larry LeBron

unread,
Jul 15, 2019, 9:48:36 PM7/15/19
to NRules Users
Just to be clear, are you saying that the number of calls to access pw.IssuerId.Value grew linearly? It makes sense that the final group size would always grow linearly, but I could imagine that the number of calls to access the parameter you're grouping by might grow exponentially depending on the sorting algorithm used under the hood.
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
Message has been deleted
0 new messages