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
14 ansible.builtin.package:
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" or
25 cpu_microarchitecture == "icelake" or
26 cpu_microarchitecture == "sapphirerapids"
28 - perf-conf-turbo-boost
30 - name: Conf - Adjust max_map_count
31 # this file contains the maximum number of memory map areas a process
32 # may have. memory map areas are used as a side-effect of calling
33 # malloc, directly by mmap and mprotect, and also when loading shared
36 # while most applications need less than a thousand maps, certain
37 # programs, particularly malloc debuggers, may consume lots of them,
38 # e.g., up to one or two maps per allocation.
39 # must be greater than or equal to (2 * vm.nr_hugepages).
40 ansible.builtin.sysctl:
41 name: "vm.max_map_count"
42 value: "{{ sysctl.vm.nr_hugepages * 4 }}"
44 sysctl_file: "/etc/sysctl.d/90-csit.conf"
49 - name: Conf - Adjust hugetlb_shm_group
50 # hugetlb_shm_group contains group id that is allowed to create sysv
51 # shared memory segment using hugetlb page.
52 ansible.builtin.sysctl:
53 name: "vm.hugetlb_shm_group"
56 sysctl_file: "/etc/sysctl.d/90-csit.conf"
61 - name: Conf - Adjust swappiness
62 # this control is used to define how aggressive the kernel will swap
63 # memory pages. higher values will increase agressiveness, lower values
64 # decrease the amount of swap. a value of 0 instructs the kernel not to
65 # initiate swap until the amount of free and file-backed pages is less
66 # than the high water mark in a zone.
67 ansible.builtin.sysctl:
71 sysctl_file: "/etc/sysctl.d/90-csit.conf"
76 - name: Conf - Adjust shmmax
77 # shared memory max must be greator or equal to the total size of hugepages.
78 # for 2mb pages, totalhugepagesize = vm.nr_hugepages * 2 * 1024 * 1024
79 # if the existing kernel.shmmax setting (cat /sys/proc/kernel/shmmax)
80 # is greater than the calculated totalhugepagesize then set this parameter
81 # to current shmmax value.
82 ansible.builtin.sysctl:
84 value: "{{ sysctl.vm.nr_hugepages * 2 * 1024 * 1024 }}"
86 sysctl_file: "/etc/sysctl.d/90-csit.conf"
91 - name: Conf - Adjust watchdog_cpumask
92 # this value can be used to control on which cpus the watchdog may run.
93 # the default cpumask is all possible cores, but if no_hz_full is
94 # enabled in the kernel config, and cores are specified with the
95 # nohz_full= boot argument, those cores are excluded by default.
96 # offline cores can be included in this mask, and if the core is later
97 # brought online, the watchdog will be started based on the mask value.
99 # typically this value would only be touched in the nohz_full case
100 # to re-enable cores that by default were not running the watchdog,
101 # if a kernel lockup was suspected on those cores.
102 ansible.builtin.sysctl:
103 name: "kernel.watchdog_cpumask"
104 value: "{{ sysctl.kernel.watchdog_cpumask }}"
106 sysctl_file: "/etc/sysctl.d/90-csit.conf"
111 - name: Conf - Adjust randomize_va_space
112 # this option can be used to select the type of process address
113 # space randomization that is used in the system, for architectures
114 # that support this feature.
115 # 0 - turn the process address space randomization off. this is the
116 # default for architectures that do not support this feature anyways,
117 # and kernels that are booted with the "norandmaps" parameter.
118 ansible.builtin.sysctl:
119 name: "kernel.randomize_va_space"
122 sysctl_file: "/etc/sysctl.d/90-csit.conf"
127 - name: Conf - Cpufrequtils
128 ansible.builtin.copy:
129 src: "files/cpufrequtils"
130 dest: "/etc/default/cpufrequtils"
135 - perf-conf-cpufrequtils
137 - name: Conf - Irqbalance
138 ansible.builtin.template:
139 src: "files/irqbalance"
140 dest: "/etc/default/irqbalance"
145 - perf-conf-irqbalance
147 - name: Conf - Kernel Parameters
148 ansible.builtin.lineinfile:
149 path: "/etc/default/grub"
151 regexp: "^GRUB_CMDLINE_LINUX="
152 line: "GRUB_CMDLINE_LINUX=\"{% for key, value in grub.items() %}{% if value is sameas true %}{{key}} {% else %}{{key}}={{value}} {% endif %}{% endfor %}\""
158 - meta: flush_handlers
160 - name: Conf - Load Kernel Modules By Default
161 ansible.builtin.lineinfile:
170 - perf-conf-load-kernel-modules
172 - name: Conf - Create a directory for 1G HugeTLBs hugepages
173 ansible.builtin.file:
174 path: "/dev/hugepages1G"
178 - perf-conf-hugepages-1g
180 - name: Conf - Mount 1G HugeTLBs hugepages
181 ansible.builtin.mount:
182 path: "/dev/hugepages1G"
189 - perf-conf-hugepages-1g
191 - name: Create a directory if it does not exist
192 ansible.builtin.file:
193 path: "/dev/hugepages2M"
197 - perf-conf-hugepages-2m
199 - name: Conf - Create a directory for 2M HugeTLBs hugepages
200 ansible.builtin.mount:
201 path: "/dev/hugepages2M"
208 - perf-conf-hugepages-2m
210 - meta: flush_handlers