Skip to content
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

Conversation

ncharles
Copy link
Member

@ncharles ncharles commented Dec 6, 2021

@@ -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
Copy link
Member Author

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

Copy link
Member

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

Copy link
Member

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

Copy link
Member Author

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))
Copy link
Member Author

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

@ncharles ncharles added WIP Use that label for a Work In Progress PR that must not be merged yet Trigger test and removed WIP Use that label for a Work In Progress PR that must not be merged yet Trigger test labels Dec 6, 2021
@ncharles
Copy link
Member Author

ncharles commented Dec 7, 2021

PR updated with a new commit

@Normation-Quality-Assistant
Copy link
Contributor

This PR is not mergeable to upper versions.
Since it is "Ready for merge" you must merge it by yourself using the following command:
rudder-dev merge https://github.com/Normation/rudder/pull/4039
-- Your faithful QA
Kant merge: "Science is organized knowledge. Wisdom is organized life."
(https://ci.normation.com/jenkins/job/merge-accepted-pr/48244/console)

@VinceMacBuche
Copy link
Member

OK, squash merging this PR

@VinceMacBuche VinceMacBuche force-pushed the bug_20367/first_go_at_improving_perfs_for_rules_tree branch from 0dc0e39 to 1c1f77c Compare December 14, 2021 14:48
@VinceMacBuche VinceMacBuche merged commit 1c1f77c into Normation:branches/rudder/7.0 Dec 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants