From d3b8c9f5efa6aa9209b3ee8974dea6723d560fb8 Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Fri, 17 Jan 2025 13:25:22 -0500 Subject: [PATCH] build: update frozen toolchain to Fedora 41 with clang 19 Update from clang 18 to clang 19. perf-simple-query reports: clang 18 278102.35 tps ( 63.1 allocs/op, 0.0 logallocs/op, 14.1 tasks/op, 36056 insns/op, 16560 cycles/op, 0 errors) 288801.19 tps ( 63.0 allocs/op, 0.0 logallocs/op, 14.1 tasks/op, 36018 insns/op, 16004 cycles/op, 0 errors) 287795.23 tps ( 63.0 allocs/op, 0.0 logallocs/op, 14.1 tasks/op, 36039 insns/op, 15995 cycles/op, 0 errors) 290495.86 tps ( 63.0 allocs/op, 0.0 logallocs/op, 14.1 tasks/op, 36027 insns/op, 15939 cycles/op, 0 errors) 293116.10 tps ( 63.0 allocs/op, 0.0 logallocs/op, 14.1 tasks/op, 36020 insns/op, 15780 cycles/op, 0 errors) clang 19 284742.08 tps ( 63.1 allocs/op, 0.0 logallocs/op, 14.1 tasks/op, 35517 insns/op, 16419 cycles/op, 0 errors) 297974.97 tps ( 63.0 allocs/op, 0.0 logallocs/op, 14.1 tasks/op, 35497 insns/op, 15926 cycles/op, 0 errors) 279527.99 tps ( 63.0 allocs/op, 0.0 logallocs/op, 14.1 tasks/op, 35513 insns/op, 16724 cycles/op, 0 errors) 298229.61 tps ( 63.0 allocs/op, 0.0 logallocs/op, 14.1 tasks/op, 35494 insns/op, 15892 cycles/op, 0 errors) 297982.67 tps ( 63.0 allocs/op, 0.0 logallocs/op, 14.1 tasks/op, 35494 insns/op, 15819 cycles/op, 0 errors) So the update delivers a nice performance improvement. Optimized clang regenerated and stored in https://devpkg.scylladb.com/clang/clang-19.1.7-Fedora-41-aarch64.tar.gz https://devpkg.scylladb.com/clang/clang-19.1.7-Fedora-41-x86_64.tar.gz Script to prepare optimized clang updated, and upstreamed patch dropped. Closes scylladb/scylladb#22380 --- install-dependencies.sh | 2 +- ...Fix-EdgeCounts-vector-size-in-SetBra.patch | 90 ------------------- tools/toolchain/Dockerfile | 2 +- tools/toolchain/image | 2 +- tools/toolchain/optimized_clang.sh | 7 +- 5 files changed, 5 insertions(+), 98 deletions(-) delete mode 100644 tools/toolchain/0001-Instrumentation-Fix-EdgeCounts-vector-size-in-SetBra.patch diff --git a/install-dependencies.sh b/install-dependencies.sh index e19e38a799..838d655db3 100755 --- a/install-dependencies.sh +++ b/install-dependencies.sh @@ -112,7 +112,7 @@ fedora_packages=( rust cargo rapidxml-devel - rust-std-static-wasm32-wasi + rust-std-static-wasm32-wasip1 wabt binaryen lcov diff --git a/tools/toolchain/0001-Instrumentation-Fix-EdgeCounts-vector-size-in-SetBra.patch b/tools/toolchain/0001-Instrumentation-Fix-EdgeCounts-vector-size-in-SetBra.patch deleted file mode 100644 index 3999fbfa2e..0000000000 --- a/tools/toolchain/0001-Instrumentation-Fix-EdgeCounts-vector-size-in-SetBra.patch +++ /dev/null @@ -1,90 +0,0 @@ -From 46a4132e167aa44d8ec7776262ce2a0e6d47de59 Mon Sep 17 00:00:00 2001 -From: Avi Kivity -Date: Mon, 26 Aug 2024 17:56:45 +0300 -Subject: [PATCH] [Instrumentation] Fix EdgeCounts vector size in - SetBranchWeights (#99064) - ---- ---- - .../Instrumentation/PGOInstrumentation.cpp | 14 +++++-- - .../Coroutines/coro-pgo-setbranchweights.ll | 42 +++++++++++++++++++ - 2 files changed, 52 insertions(+), 4 deletions(-) - create mode 100644 test/Transforms/Coroutines/coro-pgo-setbranchweights.ll - -diff --git a/lib/Transforms/Instrumentation/PGOInstrumentation.cpp b/lib/Transforms/Instrumentation/PGOInstrumentation.cpp -index c20fc942e..41025b296 100644 ---- a/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp -+++ b/llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp -@@ -1571,11 +1571,17 @@ void PGOUseFunc::setBranchWeights() { - - // We have a non-zero Branch BB. - const PGOUseBBInfo &BBCountInfo = getBBInfo(&BB); -- unsigned Size = BBCountInfo.OutEdges.size(); -- SmallVector EdgeCounts(Size, 0); -+ -+ // SuccessorCount can be greater than OutEdgesCount, because -+ // removed edges don't appear in OutEdges. -+ unsigned OutEdgesCount = BBCountInfo.OutEdges.size(); -+ unsigned SuccessorCount = BB.getTerminator()->getNumSuccessors(); -+ assert(OutEdgesCount <= SuccessorCount); -+ -+ SmallVector EdgeCounts(SuccessorCount, 0); - uint64_t MaxCount = 0; -- for (unsigned s = 0; s < Size; s++) { -- const PGOUseEdge *E = BBCountInfo.OutEdges[s]; -+ for (unsigned It = 0; It < OutEdgesCount; It++) { -+ const PGOUseEdge *E = BBCountInfo.OutEdges[It]; - const BasicBlock *SrcBB = E->SrcBB; - const BasicBlock *DestBB = E->DestBB; - if (DestBB == nullptr) -diff --git a/test/Transforms/Coroutines/coro-pgo-setbranchweights.ll b/test/Transforms/Coroutines/coro-pgo-setbranchweights.ll -new file mode 100644 -index 000000000..4f5f93660 ---- /dev/null -+++ b/test/Transforms/Coroutines/coro-pgo-setbranchweights.ll -@@ -0,0 +1,42 @@ -+; RUN: rm -rf %t && split-file %s %t -+ -+; RUN: llvm-profdata merge %t/a.proftext -o %t/a.profdata -+; RUN: opt < %t/a.ll --passes=pgo-instr-use -pgo-test-profile-file=%t/a.profdata -+ -+;--- a.ll -+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" -+target triple = "x86_64-redhat-linux-gnu" -+ -+define void @_bar() presplitcoroutine personality ptr null { -+ %1 = call token @llvm.coro.save(ptr null) -+ %2 = call i8 @llvm.coro.suspend(token none, i1 false) -+ switch i8 %2, label %5 [ -+ i8 0, label %3 -+ i8 1, label %4 -+ ] -+ -+3: ; preds = %0 -+ ret void -+ -+4: ; preds = %0 -+ ret void -+ -+5: ; preds = %0 -+ ret void -+} -+ -+declare token @llvm.coro.save(ptr) -+ -+declare i8 @llvm.coro.suspend(token, i1) -+ -+;--- a.proftext -+# IR level Instrumentation Flag -+:ir -+ -+_bar -+# Func Hash: -+1063705160175073211 -+# Num Counters: -+2 -+1 -+0 --- -2.46.0 - diff --git a/tools/toolchain/Dockerfile b/tools/toolchain/Dockerfile index 8bb06cb40b..21ff2aad15 100644 --- a/tools/toolchain/Dockerfile +++ b/tools/toolchain/Dockerfile @@ -1,4 +1,4 @@ -FROM docker.io/fedora:40 +FROM docker.io/fedora:41 ARG CLANG_BUILD="SKIP" ARG CLANG_ARCHIVES diff --git a/tools/toolchain/image b/tools/toolchain/image index 00ee4fe535..987a4e77c2 100644 --- a/tools/toolchain/image +++ b/tools/toolchain/image @@ -1 +1 @@ -docker.io/scylladb/scylla-toolchain:fedora-40-20241219 +docker.io/scylladb/scylla-toolchain:fedora-41-20250205 diff --git a/tools/toolchain/optimized_clang.sh b/tools/toolchain/optimized_clang.sh index a856e62e48..1742ea6dcd 100755 --- a/tools/toolchain/optimized_clang.sh +++ b/tools/toolchain/optimized_clang.sh @@ -63,8 +63,8 @@ SCYLLA_BUILD_DIR_FULLPATH="${SCYLLA_DIR}"/"${SCYLLA_BUILD_DIR}" SCYLLA_NINJA_FILE_FULLPATH="${SCYLLA_DIR}"/"${SCYLLA_NINJA_FILE}" # Which LLVM release to build in order to compile Scylla -LLVM_CLANG_TAG=18.1.8 -CLANG_SUFFIX=18 +LLVM_CLANG_TAG=19.1.7 +CLANG_SUFFIX=19 CLANG_ARCHIVE=$(cd "${SCYLLA_DIR}" && realpath -m "${CLANG_ARCHIVE}") @@ -130,11 +130,8 @@ if [[ "${CLANG_BUILD}" = "INSTALL" ]]; then rm -rf "${CLANG_SYSROOT_DIR}" git clone https://github.com/llvm/llvm-project --branch llvmorg-"${LLVM_CLANG_TAG}" --depth=1 "${CLANG_BUILD_DIR}" - patch="$PWD/tools/toolchain/0001-Instrumentation-Fix-EdgeCounts-vector-size-in-SetBra.patch" - echo "[clang-stage1] build the compiler for collecting PGO profile" cd "${CLANG_BUILD_DIR}" - git apply "$patch" rm -rf build cmake -B build -S llvm "${CLANG_OPTS[@]}" -DLLVM_BUILD_INSTRUMENTED=IR