Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions devops/actions/run-tests/benchmark/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ runs:
shell: bash
run: |
# Compute the core range for the first NUMA node; second node is used by
# UMF. Skip the first 4 cores as the kernel is likely to schedule more
# UMF. Skip the first 3 cores as the kernel is likely to schedule more
# work on these.
CORES="$(lscpu | awk '
/NUMA node0 CPU|On-line CPU/ {line=$0}
END {
split(line, a, " ")
split(a[4], b, ",")
sub(/^0/, "4", b[1])
sub(/^0/, "3", b[1])
print b[1]
}')"
echo "CPU core range to use: $CORES"
Expand Down
37 changes: 32 additions & 5 deletions devops/scripts/benchmarks/benches/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@
import os
import shutil
import subprocess
from pathlib import Path
from abc import ABC, abstractmethod
from enum import Enum
from utils.result import BenchmarkMetadata, BenchmarkTag, Result
from pathlib import Path

from psutil import Process

from options import options
from utils.utils import download, run
from abc import ABC, abstractmethod
from utils.unitrace import get_unitrace
from utils.flamegraph import get_flamegraph
from utils.logger import log
from utils.result import BenchmarkMetadata, BenchmarkTag, Result
from utils.unitrace import get_unitrace
from utils.utils import download, run


class TracingType(Enum):
Expand Down Expand Up @@ -167,6 +170,8 @@ def run_bench(
log.debug(f"FlameGraph perf data: {perf_data_file}")
log.debug(f"FlameGraph command: {' '.join(command)}")

command = self.taskset_cmd() + command

try:
result = run(
command=command,
Expand Down Expand Up @@ -268,6 +273,28 @@ def get_metadata(self) -> dict[str, BenchmarkMetadata]:
)
}

def taskset_cmd(self) -> list[str]:
"""Returns a list of strings with taskset usage for core pinning.
Pin compute benchmarks to a CPU cores set to ensure consistent results
and non-zero CPU count measurements (e.g. avoid E-cores). Exactly 4 cores
with the maximum frequency are pinned by default to satisfy multiple threads benchmarks.
"""
available_cores = Process().cpu_affinity()
core_frequencies = []
for core in available_cores: # type: ignore
with open(
f"/sys/devices/system/cpu/cpu{core}/cpufreq/cpuinfo_max_freq"
) as f:
freq = int(f.read().strip())
core_frequencies.append((core, freq))
selected = core_frequencies[:4] # first ones have highest frequency
if len({freq for _, freq in selected}) > 1:
log.warning(
f"Selected cores for pinning have differing max frequencies: {selected}"
)
cores_list = ",".join([str(core) for core, _ in selected])
return ["taskset", "-c", cores_list]


class Suite(ABC):
@abstractmethod
Expand Down
1 change: 0 additions & 1 deletion devops/scripts/benchmarks/benches/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# See LICENSE.TXT
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

import copy
import csv
import io
import math
Expand Down
1 change: 1 addition & 0 deletions devops/scripts/benchmarks/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ mpld3==0.5.10
dataclasses-json==0.6.7
PyYAML==6.0.1
Mako==1.3.0
psutil>=7.0.0
Loading