1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
|
---
# file: roles/performance_tuning/tasks/main.yaml
- name: Inst - Update Package Cache (APT)
apt:
update_cache: true
cache_valid_time: 3600
when:
- ansible_distribution|lower == 'ubuntu'
tags:
- perf-inst-prerequisites
- name: Inst - Machine Prerequisites
package:
name: "{{ packages | flatten(levels=1) }}"
state: latest
tags:
- perf-inst-prerequisites
- name: Conf - Turbo Boost
import_tasks: turbo_boost.yaml
when: >
cpu_microarchitecture == "skylake" or
cpu_microarchitecture == "cascadelake"
tags:
- perf-conf-turbo-boost
- name: Conf - Adjust max_map_count
# this file contains the maximum number of memory map areas a process
# may have. memory map areas are used as a side-effect of calling
# malloc, directly by mmap and mprotect, and also when loading shared
# libraries.
#
# while most applications need less than a thousand maps, certain
# programs, particularly malloc debuggers, may consume lots of them,
# e.g., up to one or two maps per allocation.
# must be greater than or equal to (2 * vm.nr_hugepages).
sysctl:
name: "vm.max_map_count"
value: "{{ sysctl.vm.nr_hugepages * 4 }}"
state: "present"
sysctl_file: "/etc/sysctl.d/90-csit.conf"
reload: "yes"
tags:
- perf-conf-sysctl
- name: Conf - Adjust hugetlb_shm_group
# hugetlb_shm_group contains group id that is allowed to create sysv
# shared memory segment using hugetlb page.
sysctl:
name: "vm.hugetlb_shm_group"
value: "1000"
state: "present"
sysctl_file: "/etc/sysctl.d/90-csit.conf"
reload: "yes"
tags:
- perf-conf-sysctl
- name: Conf - Adjust swappiness
# this control is used to define how aggressive the kernel will swap
# memory pages. higher values will increase agressiveness, lower values
# decrease the amount of swap. a value of 0 instructs the kernel not to
# initiate swap until the amount of free and file-backed pages is less
# than the high water mark in a zone.
sysctl:
name: "vm.swappiness"
value: "0"
state: "present"
sysctl_file: "/etc/sysctl.d/90-csit.conf"
reload: "yes"
tags:
- perf-conf-sysctl
- name: Conf - Adjust shmmax
# shared memory max must be greator or equal to the total size of hugepages.
# for 2mb pages, totalhugepagesize = vm.nr_hugepages * 2 * 1024 * 1024
# if the existing kernel.shmmax setting (cat /sys/proc/kernel/shmmax)
# is greater than the calculated totalhugepagesize then set this parameter
# to current shmmax value.
sysctl:
name: "kernel.shmmax"
value: "{{ sysctl.vm.nr_hugepages * 2 * 1024 * 1024 }}"
state: "present"
sysctl_file: "/etc/sysctl.d/90-csit.conf"
reload: "yes"
tags:
- perf-conf-sysctl
- name: Conf - Adjust watchdog_cpumask
# this value can be used to control on which cpus the watchdog may run.
# the default cpumask is all possible cores, but if no_hz_full is
# enabled in the kernel config, and cores are specified with the
# nohz_full= boot argument, those cores are excluded by default.
# offline cores can be included in this mask, and if the core is later
# brought online, the watchdog will be started based on the mask value.
#
# typically this value would only be touched in the nohz_full case
# to re-enable cores that by default were not running the watchdog,
# if a kernel lockup was suspected on those cores.
sysctl:
name: "kernel.watchdog_cpumask"
value: "{{ sysctl.kernel.watchdog_cpumask }}"
state: "present"
sysctl_file: "/etc/sysctl.d/90-csit.conf"
reload: "yes"
tags:
- perf-conf-sysctl
- name: Conf - Adjust randomize_va_space
# this option can be used to select the type of process address
# space randomization that is used in the system, for architectures
# that support this feature.
# 0 - turn the process address space randomization off. this is the
# default for architectures that do not support this feature anyways,
# and kernels that are booted with the "norandmaps" parameter.
sysctl:
name: "kernel.randomize_va_space"
value: "0"
state: "present"
sysctl_file: "/etc/sysctl.d/90-csit.conf"
reload: "yes"
tags:
- perf-conf-sysctl
- name: Conf - Cpufrequtils
copy:
src: "files/cpufrequtils"
dest: "/etc/default/cpufrequtils"
owner: "root"
group: "root"
mode: 0644
tags:
- perf-conf-cpufrequtils
- name: Conf - Irqbalance
template:
src: "files/irqbalance"
dest: "/etc/default/irqbalance"
owner: "root"
group: "root"
mode: 0644
tags:
- perf-conf-irqbalance
- name: Conf - Set Ondemand Service To Disable
service:
name: "ondemand"
enabled: "no"
tags:
- perf-conf-ondemand
- name: Conf - Kernel Parameters
lineinfile:
path: "/etc/default/grub"
state: "present"
regexp: "^GRUB_CMDLINE_LINUX="
line: "GRUB_CMDLINE_LINUX=\"{% for key, value in grub.items() %}{% if value is sameas true %}{{key}} {% else %}{{key}}={{value}} {% endif %}{% endfor %}\""
notify:
- "Update GRUB"
tags:
- perf-conf-grub
- meta: flush_handlers
- name: Conf - Load Kernel Modules By Default
lineinfile:
path: "/etc/modules"
state: "present"
line: "{{ item }}"
with_items:
- "vfio-pci"
notify:
- "Reboot Server"
tags:
- perf-conf-load-kernel-modules
- name: Conf - Create a directory for 1G HugeTLBs hugepages
file:
path: "/dev/hugepages1G"
state: "directory"
mode: 0755
tags:
- perf-conf-hugepages-1g
- name: Conf - Mount 1G HugeTLBs hugepages
mount:
path: "/dev/hugepages1G"
src: "hugetlbfs"
opts: "pagesize=1G"
boot: false
state: "mounted"
fstype: "hugetlbfs"
tags:
- perf-conf-hugepages-1g
- name: Create a directory if it does not exist
file:
path: "/dev/hugepages2M"
state: "directory"
mode: 0755
tags:
- perf-conf-hugepages-2m
- name: Conf - Create a directory for 2M HugeTLBs hugepages
mount:
path: "/dev/hugepages2M"
src: "hugetlbfs"
opts: "pagesize=2M"
boot: false
state: "mounted"
fstype: "hugetlbfs"
tags:
- perf-conf-hugepages-2m
- meta: flush_handlers
|