Skip to content

Commit

Permalink
bench: + lock cpu frequency
Browse files Browse the repository at this point in the history
  • Loading branch information
kvs96 committed Nov 9, 2024
1 parent 2006b3d commit 9e4913e
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
13 changes: 10 additions & 3 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@ on:
description: Instance type to provision for benchmarking.
required: true
default: 'c6i.metal'
instance_max_cpu_frequency:
description: Max CPU frequency (only baremetal).
required: true
default: '3000000'
instance_disk_size:
description: Disk size (in GB) for the instance.
required: true
default: 100
default: '100'

concurrency:
group: benchmarks
Expand Down Expand Up @@ -93,7 +97,7 @@ jobs:
run: |
cd terraform/bench-runner
terraform init
terraform apply -auto-approve -var="aws_region=${{ env.AVAILABLE_REGION }}" -var="instance_type=${{ inputs.instance_type }}" -var="instance_disk_size=${{ inputs.instance_disk_size }}" -var="registration_token=${{ env.REGISTER_TOKEN }}" -var="github_run_id=${{ github.run_id }}"
terraform apply -auto-approve -var="aws_region=${{ env.AVAILABLE_REGION }}" -var="instance_type=${{ inputs.instance_type }}" -var="max_cpu_frequency=${{ inputs.instance_max_cpu_frequency }}" -var="instance_disk_size=${{ inputs.instance_disk_size }}" -var="registration_token=${{ env.REGISTER_TOKEN }}" -var="github_run_id=${{ github.run_id }}"
- name: Notify on Failure
if: failure()
Expand Down Expand Up @@ -132,6 +136,9 @@ jobs:
cargo install cargo-script
wasm-opt --version
- name: Check CPU frequency
run: sudo cpupower frequency-info | grep 'current CPU frequency'

- name: Run all benchmarks
run: |
INSTANCE_TYPE="${{ inputs.instance_type }}"
Expand Down Expand Up @@ -230,7 +237,7 @@ jobs:
run: |
cd terraform/bench-runner
terraform init
terraform destroy -auto-approve -var="aws_region=${{ needs.provision-runner.outputs.available_region }}" -var="instance_type=${{ inputs.instance_type }}" -var="instance_disk_size=${{ inputs.instance_disk_size }}" -var="registration_token=${{ env.REGISTER_TOKEN }}" -var="github_run_id=${{ github.run_id }}"
terraform destroy -auto-approve -var="aws_region=${{ needs.provision-runner.outputs.available_region }}" -var="instance_type=${{ inputs.instance_type }}" -var="max_cpu_frequency=${{ inputs.instance_max_cpu_frequency }}" -var="instance_disk_size=${{ inputs.instance_disk_size }}" -var="registration_token=${{ env.REGISTER_TOKEN }}" -var="github_run_id=${{ github.run_id }}"
- name: Notify on Failure
if: failure()
Expand Down
28 changes: 28 additions & 0 deletions terraform/bench-runner/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ variable "instance_type" {
type = string
default = "t3.micro"
}
variable "max_cpu_frequency" {
type = string
default = 6000000
}
variable "instance_disk_size" {
type = string
default = 30
Expand Down Expand Up @@ -75,6 +79,8 @@ resource "aws_instance" "bench_runner" {

user_data = <<-EOF
#!/bin/bash
cpupower frequency-set --governor performance
cpupower frequency-set --max ${var.max_cpu_frequency}
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag
echo 0 > /proc/sys/vm/nr_hugepages
Expand All @@ -85,6 +91,12 @@ resource "aws_instance" "bench_runner" {
systemctl enable --now docker
usermod -aG docker ubuntu
mkdir -p /home/ubuntu/.ssh
chmod 700 /home/ubuntu/.ssh
echo "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGd8nO78hzAVTjGaW6IJgFnI32qY/vCpQRpO8lW97eXA root" >> /home/ubuntu/.ssh/authorized_keys
chown -R ubuntu:ubuntu /home/ubuntu/.ssh
chmod 600 /home/ubuntu/.ssh/authorized_keys
sudo -u ubuntu -i bash -c "
cd /runner &&
curl -o actions-runner-linux-x64.tar.gz -L `curl -s https://api.github.com/repos/actions/runner/releases/latest | jq -r '.assets[] | select(.name | contains(\"actions-runner-linux-x64\")) | .browser_download_url'` &&
Expand All @@ -104,3 +116,19 @@ resource "aws_instance" "bench_runner" {
delete = "60m"
}
}

output "instance_region" {
value = var.aws_region
}
output "instance_name" {
value = aws_instance.bench_runner.tags["Name"]
}
output "instance_type" {
value = var.instance_type
}
output "max_cpu_frequency" {
value = "${var.max_cpu_frequency} MHz"
}
output "instance_public_ip" {
value = aws_instance.bench_runner.public_ip
}

0 comments on commit 9e4913e

Please sign in to comment.