-
Notifications
You must be signed in to change notification settings - Fork 74
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
Fixes #20367: first go at improving perfs for rules/tree #4039
Fixes #20367: first go at improving perfs for rules/tree #4039
Conversation
@@ -755,10 +755,11 @@ class RuleApiService14 ( | |||
|
|||
def getRuleApplicationStatus(rule: Rule, groupLib: FullNodeGroupCategory, directiveLib: FullActiveTechniqueCategory, nodesLib: Map[NodeId, NodeInfo], globalMode: GlobalPolicyMode): RuleApplicationStatus = { | |||
val directives = rule.directiveIds.flatMap(directiveLib.allDirectives.get(_)).map{case (a,d)=> (a.toActiveTechnique(), d)} | |||
val nodes = groupLib.getNodeIds(rule.targets, nodesLib).flatMap(nodesLib.get) | |||
val nodesIds = groupLib.getNodeIds(rule.targets, nodesLib) | |||
val nodes = nodesLib.view.filterKeys( x => nodesIds.contains(x)).values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
impact of this is simply delirious. it goes from 9s to 6s with only this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a comment ? If it is significatif, it must be kept in futur refactoring
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a unit test would be more futur proof, but I have no idea how to build a relevant test for that, that won't fail randomly depending of the machine, and so being just noise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm unsure also, because all other perfs tests are disabled :(
val allTargets = rule.targets.flatMap(groupLib.allTargets.get).map(_.toTargetInfo) | ||
val policyMode = ComputePolicyMode.ruleMode(globalMode, directives.map(_._2), nodes.map(_.policyMode)) | ||
val applicationStatus = applicationService.isApplied(rule,groupLib,directiveLib,nodesLib) | ||
val applicationStatus = applicationService.isApplied(rule,groupLib,directiveLib,nodesLib, Some(nodesIds)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we shave again 2s with that
PR updated with a new commit |
This PR is not mergeable to upper versions. |
OK, squash merging this PR |
0dc0e39
to
1c1f77c
Compare
https://issues.rudder.io/issues/20367