|
18 | 18 | - "env:{{ vars_environment }}"
|
19 | 19 | - "service:rustc-perf"
|
20 | 20 | process_config:
|
21 |
| - enabled: "true" |
| 21 | + enabled: "false" |
| 22 | + |
| 23 | + tasks: |
| 24 | + # Create user account used for benchmarking |
| 25 | + - name: Create the 'collector' user |
| 26 | + user: |
| 27 | + name: collector |
| 28 | + shell: /bin/bash |
| 29 | + create_home: yes |
| 30 | + |
| 31 | + # Setup build dependencies |
| 32 | + - name: install apt packages |
| 33 | + apt: |
| 34 | + name: |
| 35 | + # For compilation of C/C++ dependencies and linking |
| 36 | + - build-essential |
| 37 | + - pkg-config |
| 38 | + - cmake |
| 39 | + - libssl-dev |
| 40 | + # For `perf` and `cpupower` to work |
| 41 | + - linux-tools-generic |
| 42 | + - linux-cloud-tools-generic |
| 43 | + state: present |
| 44 | + |
| 45 | + # Install rustup/rustc/cargo |
| 46 | + - name: check if cargo is installed |
| 47 | + become: yes |
| 48 | + become_user: collector |
| 49 | + shell: | |
| 50 | + test -f ~/.cargo/env && . ~/.cargo/env && command -v cargo |
| 51 | + register: cargo_exists |
| 52 | + ignore_errors: yes |
| 53 | + |
| 54 | + - name: Download Installer |
| 55 | + when: cargo_exists is failed |
| 56 | + become: yes |
| 57 | + become_user: collector |
| 58 | + get_url: |
| 59 | + url: https://sh.rustup.rs |
| 60 | + dest: /tmp/sh.rustup.rs |
| 61 | + mode: '0755' |
| 62 | + force: 'yes' |
| 63 | + |
| 64 | + - name: install rust/cargo |
| 65 | + become: yes |
| 66 | + become_user: collector |
| 67 | + when: cargo_exists is failed |
| 68 | + shell: /tmp/sh.rustup.rs -y |
| 69 | + |
| 70 | + # Configure profiling and low-noise parameters |
| 71 | + - name: Set kernel.perf_event_paranoid to -1 to enable profiling |
| 72 | + sysctl: |
| 73 | + name: kernel.perf_event_paranoid |
| 74 | + value: -1 |
| 75 | + state: present |
| 76 | + sysctl_set: yes |
| 77 | + reload: yes |
| 78 | + |
| 79 | + - name: Disable watchdog to reduce interrupts and noise |
| 80 | + sysctl: |
| 81 | + name: kernel.nmi_watchdog |
| 82 | + value: 0 |
| 83 | + state: present |
| 84 | + sysctl_set: yes |
| 85 | + reload: yes |
| 86 | + |
| 87 | + - name: Disable ASLR to reduce noise |
| 88 | + sysctl: |
| 89 | + name: kernel.randomize_va_space |
| 90 | + value: 0 |
| 91 | + state: present |
| 92 | + sysctl_set: yes |
| 93 | + reload: yes |
| 94 | + |
| 95 | + - name: Discourage swapping |
| 96 | + sysctl: |
| 97 | + name: vm.swappiness |
| 98 | + value: 10 |
| 99 | + state: present |
| 100 | + sysctl_set: yes |
| 101 | + reload: yes |
| 102 | + |
| 103 | + - name: Create systemd service to disable hyper-threading and frequency scaling |
| 104 | + copy: |
| 105 | + dest: /etc/systemd/system/low-noise.service |
| 106 | + content: | |
| 107 | + [Unit] |
| 108 | + Description=Disable hyper-threading and frequency scaling at boot |
| 109 | + After=multi-user.target |
| 110 | +
|
| 111 | + [Service] |
| 112 | + Type=oneshot |
| 113 | + ExecStart=/bin/sh -c 'echo off > /sys/devices/system/cpu/smt/control; cpupower frequency-set -g performance' |
| 114 | + RemainAfterExit=yes |
| 115 | +
|
| 116 | + [Install] |
| 117 | + WantedBy=multi-user.target |
| 118 | + become: yes |
| 119 | + |
| 120 | + - name: Enable low-noise service |
| 121 | + systemd: |
| 122 | + name: low-noise.service |
| 123 | + enabled: yes |
| 124 | + daemon_reload: yes |
| 125 | + become: yes |
| 126 | + |
| 127 | + # Periodically clean old entries in /tmp |
| 128 | + - name: Configure systemd-tmpfiles to clean old /tmp dirs |
| 129 | + copy: |
| 130 | + dest: /etc/tmpfiles.d/tmp-clean.conf |
| 131 | + content: | |
| 132 | + D /tmp 1777 root root 7d |
| 133 | + mode: '0644' |
| 134 | + owner: root |
| 135 | + group: root |
| 136 | + become: yes |
| 137 | + |
| 138 | + - name: Ensure systemd-tmpfiles-clean.timer is enabled |
| 139 | + systemd: |
| 140 | + name: systemd-tmpfiles-clean.timer |
| 141 | + enabled: yes |
| 142 | + state: started |
| 143 | + become: yes |
| 144 | + |
| 145 | + # Configure the rustc-perf service |
| 146 | + - name: Checkout rustc-perf |
| 147 | + ansible.builtin.git: |
| 148 | + # The version isn't important, as the benchmarking script will auto-update itself |
| 149 | + repo: "https://github.com/rust-lang/rustc-perf.git" |
| 150 | + dest: /home/collector/rustc-perf |
| 151 | + become: yes |
| 152 | + become_user: collector |
| 153 | + |
| 154 | + - name: Create systemd service to run rustc-perf |
| 155 | + copy: |
| 156 | + dest: /etc/systemd/system/collector.service |
| 157 | + content: | |
| 158 | + [Unit] |
| 159 | + Description=rustc-perf collector |
| 160 | + After=network.target |
| 161 | +
|
| 162 | + [Service] |
| 163 | + ExecStart=/home/collector/rustc-perf/run.sh |
| 164 | + WorkingDirectory=/home/collector/rustc-perf |
| 165 | + User=collector |
| 166 | + Group=collector |
| 167 | + Restart=always |
| 168 | +
|
| 169 | + [Install] |
| 170 | + WantedBy=multi-user.target |
| 171 | + become: yes |
| 172 | + |
| 173 | + - name: Enable collector service |
| 174 | + systemd: |
| 175 | + name: collector.service |
| 176 | + enabled: yes |
| 177 | + daemon_reload: yes |
| 178 | + become: yes |
0 commit comments