2 # file: roles/performance_tuning/tasks/main.yaml
4 - name: Inst - Update Package Cache (APT)
9 - ansible_distribution|lower == 'ubuntu'
11 - perf-inst-prerequisites
13 - name: Inst - Machine Prerequisites
15 name: "{{ packages | flatten(levels=1) }}"
18 - perf-inst-prerequisites
20 - name: Conf - Turbo Boost
21 import_tasks: turbo_boost.yaml
23 cpu_microarchitecture == "skylake" or
24 cpu_microarchitecture == "cascadelake"
26 - perf-conf-turbo-boost
28 - name: Conf - Adjust max_map_count
29 # this file contains the maximum number of memory map areas a process
30 # may have. memory map areas are used as a side-effect of calling
31 # malloc, directly by mmap and mprotect, and also when loading shared
34 # while most applications need less than a thousand maps, certain
35 # programs, particularly malloc debuggers, may consume lots of them,
36 # e.g., up to one or two maps per allocation.
37 # must be greater than or equal to (2 * vm.nr_hugepages).
39 name: "vm.max_map_count"
40 value: "{{ sysctl.vm.nr_hugepages * 4 }}"
42 sysctl_file: "/etc/sysctl.d/90-csit.conf"
47 - name: Conf - Adjust hugetlb_shm_group
48 # hugetlb_shm_group contains group id that is allowed to create sysv
49 # shared memory segment using hugetlb page.
51 name: "vm.hugetlb_shm_group"
54 sysctl_file: "/etc/sysctl.d/90-csit.conf"
59 - name: Conf - Adjust swappiness
60 # this control is used to define how aggressive the kernel will swap
61 # memory pages. higher values will increase agressiveness, lower values
62 # decrease the amount of swap. a value of 0 instructs the kernel not to
63 # initiate swap until the amount of free and file-backed pages is less
64 # than the high water mark in a zone.
69 sysctl_file: "/etc/sysctl.d/90-csit.conf"
74 - name: Conf - Adjust shmmax
75 # shared memory max must be greator or equal to the total size of hugepages.
76 # for 2mb pages, totalhugepagesize = vm.nr_hugepages * 2 * 1024 * 1024
77 # if the existing kernel.shmmax setting (cat /sys/proc/kernel/shmmax)
78 # is greater than the calculated totalhugepagesize then set this parameter
79 # to current shmmax value.
82 value: "{{ sysctl.vm.nr_hugepages * 2 * 1024 * 1024 }}"
84 sysctl_file: "/etc/sysctl.d/90-csit.conf"
89 - name: Conf - Adjust watchdog_cpumask
90 # this value can be used to control on which cpus the watchdog may run.
91 # the default cpumask is all possible cores, but if no_hz_full is
92 # enabled in the kernel config, and cores are specified with the
93 # nohz_full= boot argument, those cores are excluded by default.
94 # offline cores can be included in this mask, and if the core is later
95 # brought online, the watchdog will be started based on the mask value.
97 # typically this value would only be touched in the nohz_full case
98 # to re-enable cores that by default were not running the watchdog,
99 # if a kernel lockup was suspected on those cores.
101 name: "kernel.watchdog_cpumask"
102 value: "{{ sysctl.kernel.watchdog_cpumask }}"
104 sysctl_file: "/etc/sysctl.d/90-csit.conf"
109 - name: Conf - Adjust randomize_va_space
110 # this option can be used to select the type of process address
111 # space randomization that is used in the system, for architectures
112 # that support this feature.
113 # 0 - turn the process address space randomization off. this is the
114 # default for architectures that do not support this feature anyways,
115 # and kernels that are booted with the "norandmaps" parameter.
117 name: "kernel.randomize_va_space"
120 sysctl_file: "/etc/sysctl.d/90-csit.conf"
125 - name: Conf - Cpufrequtils
127 src: "files/cpufrequtils"
128 dest: "/etc/default/cpufrequtils"
133 - perf-conf-cpufrequtils
135 - name: Conf - Irqbalance
137 src: "files/irqbalance"
138 dest: "/etc/default/irqbalance"
143 - perf-conf-irqbalance
145 - name: Conf - Set Ondemand Service To Disable
152 - name: Conf - Kernel Parameters
154 path: "/etc/default/grub"
156 regexp: "^GRUB_CMDLINE_LINUX="
157 line: "GRUB_CMDLINE_LINUX=\"{% for key, value in grub.items() %}{% if value is sameas true %}{{key}} {% else %}{{key}}={{value}} {% endif %}{% endfor %}\""
163 - meta: flush_handlers
165 - name: Conf - Load Kernel Modules By Default
175 - perf-conf-load-kernel-modules
177 - name: Conf - Create a directory for 1G HugeTLBs hugepages
179 path: "/dev/hugepages1G"
183 - perf-conf-hugepages-1g
185 - name: Conf - Mount 1G HugeTLBs hugepages
187 path: "/dev/hugepages1G"
194 - perf-conf-hugepages-1g
196 - name: Create a directory if it does not exist
198 path: "/dev/hugepages2M"
202 - perf-conf-hugepages-2m
204 - name: Conf - Create a directory for 2M HugeTLBs hugepages
206 path: "/dev/hugepages2M"
213 - perf-conf-hugepages-2m
215 - meta: flush_handlers