Project

General

Profile

Actions

Bug #13859

closed

Load all ncf files in one go (or two)

Added by Nicolas CHARLES about 6 years ago. Updated almost 6 years ago.

Status:
Released
Priority:
N/A
Category:
Performance and scalability
Target version:
Severity:
UX impact:
User visibility:
Effort required:
Priority:
0
Name check:
Fix check:
Regression:

Description

Now that the agent supports quite large list, we can revert the splitting of loading policy files from 11 call, to only one or two

Testing on a 4.3 Rudder, moving from the old

      "path_ncf_common_inputs_10" slist => splitstring(execresult("${compatible_inputs_cmd} common/10_ncf_internals", "${shell_type}"), "\n", 10000);
      "path_ncf_common_inputs_20" slist => splitstring(execresult("${compatible_inputs_cmd} common/20_cfe_basics", "${shell_type}"), "\n", 10000);
      "path_ncf_common_inputs_30" slist => splitstring(execresult("${compatible_inputs_cmd} common/30_generic_methods", "${shell_type}"), "\n", 10000);
      "path_ncf_common_inputs_40" slist => splitstring(execresult("${compatible_inputs_cmd} common/40_it_ops_knowledge", "${shell_type}"), "\n", 10000);
      "path_ncf_common_inputs_50" slist => splitstring(execresult("${compatible_inputs_cmd} common/50_techniques", "${shell_type}"), "\n", 10000);
      "path_ncf_common_inputs_60" slist => splitstring(execresult("${compatible_inputs_cmd} common/60_services", "${shell_type}"), "\n", 10000);

      "path_ncf_local_inputs_10" slist => splitstring(execresult("${compatible_inputs_cmd} local/10_ncf_internals", "${shell_type}"), "\n", 10000);
      "path_ncf_local_inputs_20" slist => splitstring(execresult("${compatible_inputs_cmd} local/20_cfe_basics", "${shell_type}"), "\n", 10000);
      "path_ncf_local_inputs_30" slist => splitstring(execresult("${compatible_inputs_cmd} local/30_generic_methods", "${shell_type}"), "\n", 10000);
      "path_ncf_local_inputs_40" slist => splitstring(execresult("${compatible_inputs_cmd} local/40_it_ops_knowledge", "${shell_type}"), "\n", 10000);
      # Files from 50_techniques are automatically included by Rudder's metadata.xml mechanism
      "path_ncf_local_inputs_60" slist => splitstring(execresult("${compatible_inputs_cmd} local/60_services", "${shell_type}"), "\n", 10000);

      # Must concatenate all lists + filter, as maplist on an empty element returns cf_null
      "raw_path_ncf_inputs" slist => { @{path_ncf_common_inputs_10}, @{path_ncf_local_inputs_10}, @{path_ncf_common_inputs_20}, @{path_ncf_local_inputs_20}, @{path_ncf_common_inputs_30}, @{path_ncf_local_inputs_30}, @{path_ncf_common_inputs_40}, @{path_ncf_local_inputs_40}, @{path_ncf_common_inputs_50}, @{path_ncf_common_inputs_60}, @{path_ncf_local_inputs_60}},
                           policy => "ifdefined" 

to

       "path_ncf_common_inputs" slist => splitstring(execresult("${compatible_inputs_cmd} common", "${shell_type}"), "\n", 10000);
       "raw_path_ncf_local_inputs" slist => splitstring(execresult("${compatible_inputs_cmd} local", "${shell_type}"), "\n", 10000);

       # filtering out 50_techniques from local list
      "path_ncf_local_inputs" slist  => filter("/var/rudder/ncf/local/50_techniques.*", "raw_path_ncf_local_inputs", "true", "false", 10000);

      "raw_path_ncf_inputs" slist => { @{path_ncf_common_inputs}, @{path_ncf_local_inputs}},
                           policy => "ifdefined";

improves the perf of the policy validation from 1.4s to 1s

Before

orchestrateur-3:~ # /usr/bin/time /var/rudder/cfengine-community/bin/cf-promises -f /var/rudder/cfengine-community/inputs/promises.cf 
real    0m1.440s
user    0m0.900s
sys    0m0.132s
orchestrateur-3:~ # /usr/bin/time /var/rudder/cfengine-community/bin/cf-promises -f /var/rudder/cfengine-community/inputs/promises.cf 
0.87user 0.15system 0:01.43elapsed 71%CPU (0avgtext+0avgdata 15604maxresident)k
0inputs+8outputs (0major+219905minor)pagefaults 0swaps

## Summary #####################################################################
   => 59 components in Enforce mode
      -> 51 compliant
      -> 2 repaired
      -> 6 not-applicable
Execution time: 7.65s

After

 time /var/rudder/cfengine-community/bin/cf-promises -f /var/rudder/cfengine-community/inputs/promises.cf 

real    0m0.947s
user    0m0.760s
sys    0m0.084s

# /usr/bin/time /var/rudder/cfengine-community/bin/cf-promises -f /var/rudder/cfengine-community/inputs/promises.cf 
0.85user 0.04system 0:01.00elapsed 90%CPU (0avgtext+0avgdata 15004maxresident)k
0inputs+0outputs (0major+50985minor)pagefaults 0swaps

We could also improve it again by changing the script that would load only once everything.

caution : i had to purge the cf files in /usr/share/ncf/tree


Files

list-compatible-inputs-ng (8.02 KB) list-compatible-inputs-ng Nicolas CHARLES, 2018-11-19 14:49
Actions

Also available in: Atom PDF