Skip to content

Commit

Permalink
compare the system llvm against "big-merge" and "pgo"
Browse files Browse the repository at this point in the history
  • Loading branch information
kwk committed Aug 26, 2024
1 parent b21d85c commit c71bf57
Show file tree
Hide file tree
Showing 4 changed files with 191 additions and 0 deletions.
42 changes: 42 additions & 0 deletions scripts/perf/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM fedora:40
LABEL description="Test compilers with llvm-test-suite"

USER root
WORKDIR /root

# Install deps to run test-suite
RUN dnf install -y \
cmake \
fedora-packager \
git \
python3-pip \
python3-virtualenv \
python3-lit \
ninja-build \
which \
coreutils \
tcl \
tcl-devel \
tcl-tclreadline \
tcl-tclxml-devel \
tcl-tclxml \
tcl-zlib \
tcl-thread-devel

RUN virtualenv ~/mysandbox
RUN source ~/mysandbox/bin/activate \
&& pip install \
pandas \
scipy

# Clone test suite (in correct version for installed clang version)
# See https://llvm.org/docs/TestSuiteGuide.html
# RUN export VERSION=`clang --version | grep -ioP 'clang version\s\K[0-9\.]+'` \
# && git clone --depth=1 --branch llvmorg-${VERSION} https://github.com/llvm/llvm-test-suite.git test-suite
RUN git clone --depth=1 https://github.com/llvm/llvm-test-suite.git test-suite

RUN dnf install -y 'dnf-command(copr)' perf

COPY entrypoint.sh /root/entrypoint.sh
USER root
ENTRYPOINT [ "/root/entrypoint.sh" ]
4 changes: 4 additions & 0 deletions scripts/perf/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.PHONY: all
all:
podman build -t evaluation .
podman run -it evaluation
27 changes: 27 additions & 0 deletions scripts/perf/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# README

This container setup allows you to compare the system llvm against "big-merge" and "pgo".

# How to

Just run `make` to build and run the container image. It takes a long time to complete.

Then you'll be promted to a terminal in the container where you'll find these files:

```
~/results-system-vs-pgo.txt
~/results-system-vs-big-merge.txt
~/results-big-merge-vs-pgo.txt
```

The names speak for themselves.

## How to change to OS

If you want to change the version of the operating system, go to `Containerfile` and change the line that looks like this: `FROM fedora:40`. Change it to `FROM fedora:41` or something else.

Then run `make` again.

## How to change the date for which to compare results?

Go to `entrypoint.sh` and change the line that defines `yyyymmdd` to the year-month-date of your liking.
118 changes: 118 additions & 0 deletions scripts/perf/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#!/usr/bin/bash

set -x

# Source the python environment with required packages
source ~/mysandbox/bin/activate

function configure_build_run {
# Configure the test suite
cmake \
-DCMAKE_GENERATOR=Ninja \
-DCMAKE_C_COMPILER=/usr/bin/clang \
-DCMAKE_CXX_COMPILER=/usr/bin/clang++ \
-C~/test-suite/cmake/caches/O3.cmake \
~/test-suite

# Build the test-suite
ninja -j30

# Run the tests with lit:
lit -j1 -v -o results.json . || true
}

# Query version information for given day
yyyymmdd=20240825
git_rev=$(curl -sL https://github.com/fedora-llvm-team/llvm-snapshots/releases/download/snapshot-version-sync/llvm-git-revision-${yyyymmdd}.txt)
git_rev_short="${git_rev:0:14}"
llvm_release=$(curl -sL https://github.com/fedora-llvm-team/llvm-snapshots/releases/download/snapshot-version-sync/llvm-release-${yyyymmdd}.txt)
rpm_suffix="${llvm_release}~pre${yyyymmdd}.g${git_rev_short}"

echo "git_rev=$git_rev"
echo "git_rev_short=$git_rev_short"
echo "llvm_release=$llvm_release"
echo "rpm_suffix=$rpm_suffix"

######################################################################################
# PGO
######################################################################################

# Install and enable the repository that provides the PGO LLVM Toolchain
# See https://llvm.org/docs/HowToBuildWithPGO.html#building-clang-with-pgo
dnf copr enable -y @fedora-llvm-team/llvm-snapshots-pgo-${yyyymmdd}
dnf install -y \
clang-${rpm_suffix} \
clang-${rpm_suffix} \
clang-libs-${rpm_suffix} \
clang-resource-filesystem-${rpm_suffix} \
llvm-${rpm_suffix} \
llvm-libs-${rpm_suffix}

mkdir -pv ~/pgo
cd ~/pgo

configure_build_run
# Remove packages from that PGO repo and the repo itself
dnf -y repository-packages copr:copr.fedorainfracloud.org:group_fedora-llvm-team:llvm-snapshots-pgo-${yyyymmdd} remove
dnf -y copr remove @fedora-llvm-team/llvm-snapshots-pgo-${yyyymmdd}

######################################################################################
# big-merge
######################################################################################

# Install and enable the repository that provides the big-merge LLVM Toolchain
dnf copr enable -y @fedora-llvm-team/llvm-snapshots-big-merge-${yyyymmdd}
dnf install -y \
clang-${rpm_suffix} \
clang-${rpm_suffix} \
clang-libs-${rpm_suffix} \
clang-resource-filesystem-${rpm_suffix} \
llvm-${rpm_suffix} \
llvm-libs-${rpm_suffix}

mkdir -pv ~/big-merge
cd ~/big-merge

configure_build_run
# Remove packages from that big-merge repo and the repo itself
dnf -y repository-packages copr:copr.fedorainfracloud.org:group_fedora-llvm-team:llvm-snapshots-big-merge-${yyyymmdd} remove
dnf -y copr remove @fedora-llvm-team/llvm-snapshots-big-merge-${yyyymmdd}

######################################################################################
# system llvm
######################################################################################

# Build with regular clang
dnf install -y clang clang-libs clang-resource-filesystem llvm llvm-libs
mkdir -pv ~/system
cd ~/system

configure_build_run

system_llvm_release=$(clang --version | grep -Po '[0-9]+\.[0-9]+\.[0-9]' | head -n1)

/root/test-suite/utils/compare.py \
--metric exec_time \
--metric compile_time \
--metric link_time \
--lhs-name ${system_llvm_release} \
--rhs-name pgo-${rpm_suffix} \
~/system/results.json vs ~/pgo/results.json > ~/results-system-vs-pgo.txt || true

/root/test-suite/utils/compare.py \
--metric exec_time \
--metric compile_time \
--metric link_time \
--lhs-name ${system_llvm_release} \
--rhs-name big-merge-${rpm_suffix} \
~/system/results.json vs ~/big-merge/results.json > ~/results-system-vs-big-merge.txt || true

/root/test-suite/utils/compare.py \
--metric exec_time \
--metric compile_time \
--metric link_time \
--lhs-name big-merge-${rpm_suffix} \
--rhs-name pgo-${rpm_suffix} \
~/big-merge/results.json vs ~/pgo/results.json > ~/results-big-merge-vs-pgo.txt || true

bash

0 comments on commit c71bf57

Please sign in to comment.