2 # file: roles/performance_tuning/tasks/main.yaml
4 - name: Performance Tuning - Install Distribution - Release - Machine Prerequisites
6 name: "{{ packages | flatten(levels=1) }}"
10 - install-dependencies
12 - name: Performance Tuning - Distribution - release - machine optimizations
13 include_tasks: '{{ ansible_distribution|lower }}_{{ ansible_distribution_release }}.yaml'
15 - machine-optimizations
17 - name: Performance Tuning - Configure {{ ansible_machine }} Kernel Parameters
19 path: "/etc/default/grub"
21 regexp: "^GRUB_CMDLINE_LINUX="
22 line: "{{ grub_cmdline_linux[ansible_machine] | join() }}"
29 - name: Performance Tuning - Turbo Boost
30 import_tasks: turbo_boost.yaml
32 cpu_microarchitecture == "skylake" or
33 cpu_microarchitecture == "cascadelake"
37 - name: Performance Tuning - Adjust nr_hugepages
38 # change the minimum size of the hugepage pool.
39 # 2G VPP, 4GB per VNF/CNF, 2G reserve
41 name: "vm.nr_hugepages"
42 value: "{{ sysctl.vm.nr_hugepages }}"
44 sysctl_file: "/etc/sysctl.d/90-csit.conf"
49 - name: Performance Tuning - Adjust max_map_count
50 # this file contains the maximum number of memory map areas a process
51 # may have. memory map areas are used as a side-effect of calling
52 # malloc, directly by mmap and mprotect, and also when loading shared
55 # while most applications need less than a thousand maps, certain
56 # programs, particularly malloc debuggers, may consume lots of them,
57 # e.g., up to one or two maps per allocation.
58 # must be greater than or equal to (2 * vm.nr_hugepages).
60 name: "vm.max_map_count"
61 value: "{{ sysctl.vm.nr_hugepages * 4 }}"
63 sysctl_file: "/etc/sysctl.d/90-csit.conf"
68 - name: Performance Tuning - Adjust hugetlb_shm_group
69 # hugetlb_shm_group contains group id that is allowed to create sysv
70 # shared memory segment using hugetlb page.
72 name: "vm.hugetlb_shm_group"
75 sysctl_file: "/etc/sysctl.d/90-csit.conf"
80 - name: Performance Tuning - Adjust swappiness
81 # this control is used to define how aggressive the kernel will swap
82 # memory pages. higher values will increase agressiveness, lower values
83 # decrease the amount of swap. a value of 0 instructs the kernel not to
84 # initiate swap until the amount of free and file-backed pages is less
85 # than the high water mark in a zone.
90 sysctl_file: "/etc/sysctl.d/90-csit.conf"
95 - name: Performance Tuning - Adjust shmmax
96 # shared memory max must be greator or equal to the total size of hugepages.
97 # for 2mb pages, totalhugepagesize = vm.nr_hugepages * 2 * 1024 * 1024
98 # if the existing kernel.shmmax setting (cat /sys/proc/kernel/shmmax)
99 # is greater than the calculated totalhugepagesize then set this parameter
100 # to current shmmax value.
102 name: "kernel.shmmax"
103 value: "{{ sysctl.vm.nr_hugepages * 2 * 1024 * 1024 }}"
105 sysctl_file: "/etc/sysctl.d/90-csit.conf"
110 - name: Performance Tuning - Adjust watchdog_cpumask
111 # this value can be used to control on which cpus the watchdog may run.
112 # the default cpumask is all possible cores, but if no_hz_full is
113 # enabled in the kernel config, and cores are specified with the
114 # nohz_full= boot argument, those cores are excluded by default.
115 # offline cores can be included in this mask, and if the core is later
116 # brought online, the watchdog will be started based on the mask value.
118 # typically this value would only be touched in the nohz_full case
119 # to re-enable cores that by default were not running the watchdog,
120 # if a kernel lockup was suspected on those cores.
122 name: "kernel.watchdog_cpumask"
123 value: "{{ sysctl.kernel.watchdog_cpumask }}"
125 sysctl_file: "/etc/sysctl.d/90-csit.conf"
130 - name: Performance Tuning - Adjust randomize_va_space
131 # this option can be used to select the type of process address
132 # space randomization that is used in the system, for architectures
133 # that support this feature.
134 # 0 - turn the process address space randomization off. this is the
135 # default for architectures that do not support this feature anyways,
136 # and kernels that are booted with the "norandmaps" parameter.
138 name: "kernel.randomize_va_space"
141 sysctl_file: "/etc/sysctl.d/90-csit.conf"
146 - name: Performance Tuning - Copy Cpufrequtils File
148 src: "files/cpufrequtils"
149 dest: "/etc/default/cpufrequtils"
156 - name: Performance Tuning - Copy Irqbalance File
158 src: "files/irqbalance"
159 dest: "/etc/default/irqbalance"
166 - name: Performance Tuning - Set Ondemand Service To Disable
173 - name: Performance Tuning - Load Kernel Modules By Default
181 - load-kernel-modules
183 - meta: flush_handlers