Skip to content

Conversation

philnik777
Copy link
Contributor

Having truly random data makes it quite difficult to compare benchmark results, since a significant amount of difference can simply be due to different input data. Making the data determinisic helps a lot when trying to figure out whether specific changes indeed improve the performance.

@philnik777 philnik777 requested a review from a team as a code owner September 18, 2025 08:57
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Sep 18, 2025
@llvmbot
Copy link
Member

llvmbot commented Sep 18, 2025

@llvm/pr-subscribers-libcxx

Author: Nikolas Klauser (philnik777)

Changes

Having truly random data makes it quite difficult to compare benchmark results, since a significant amount of difference can simply be due to different input data. Making the data determinisic helps a lot when trying to figure out whether specific changes indeed improve the performance.


Full diff: https://github.com/llvm/llvm-project/pull/159525.diff

1 Files Affected:

  • (modified) libcxx/test/benchmarks/GenerateInput.h (+1-1)
diff --git a/libcxx/test/benchmarks/GenerateInput.h b/libcxx/test/benchmarks/GenerateInput.h
index 06387852f76a6..d07cb8857579d 100644
--- a/libcxx/test/benchmarks/GenerateInput.h
+++ b/libcxx/test/benchmarks/GenerateInput.h
@@ -25,7 +25,7 @@ static const char Letters[] = {
 static const std::size_t LettersSize = sizeof(Letters);
 
 inline std::default_random_engine& getRandomEngine() {
-  static std::default_random_engine RandEngine(std::random_device{}());
+  static std::default_random_engine RandEngine(123456);
   return RandEngine;
 }
 

@ldionne
Copy link
Member

ldionne commented Sep 23, 2025

Can you confirm that you don't see any wild differences when running the microbenchmarks before and after this patch?

@philnik777
Copy link
Contributor Author

Can you confirm that you don't see any wild differences when running the microbenchmarks before and after this patch?

I've checked with vector.bench.cpp and string.bench.cpp and didn't see anything out of the ordinary.

@philnik777 philnik777 merged commit 52ede49 into llvm:main Sep 24, 2025
71 of 80 checks passed
@philnik777 philnik777 deleted the make_benchmarks_pseudo_random branch September 24, 2025 11:57
mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Oct 3, 2025
Having truly random data makes it quite difficult to compare benchmark
results, since a significant amount of difference can simply be due to
different input data. Making the data determinisic helps a lot when
trying to figure out whether specific changes indeed improve the
performance.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants