aboutsummaryrefslogtreecommitdiff
path: root/src/bench
diff options
context:
space:
mode:
Diffstat (limited to 'src/bench')
-rw-r--r--src/bench/crypto_hash.cpp127
-rw-r--r--src/bench/disconnected_transactions.cpp6
-rw-r--r--src/bench/wallet_create_tx.cpp2
3 files changed, 125 insertions, 10 deletions
diff --git a/src/bench/crypto_hash.cpp b/src/bench/crypto_hash.cpp
index cf8d807d7b..1685a120b4 100644
--- a/src/bench/crypto_hash.cpp
+++ b/src/bench/crypto_hash.cpp
@@ -13,6 +13,7 @@
#include <crypto/siphash.h>
#include <hash.h>
#include <random.h>
+#include <tinyformat.h>
#include <uint256.h>
/* Number of bytes to hash per iteration */
@@ -36,13 +37,48 @@ static void SHA1(benchmark::Bench& bench)
});
}
-static void SHA256(benchmark::Bench& bench)
+static void SHA256_STANDARD(benchmark::Bench& bench)
{
+ bench.name(strprintf("%s using the '%s' SHA256 implementation", __func__, SHA256AutoDetect(sha256_implementation::STANDARD)));
uint8_t hash[CSHA256::OUTPUT_SIZE];
std::vector<uint8_t> in(BUFFER_SIZE,0);
bench.batch(in.size()).unit("byte").run([&] {
CSHA256().Write(in.data(), in.size()).Finalize(hash);
});
+ SHA256AutoDetect();
+}
+
+static void SHA256_SSE4(benchmark::Bench& bench)
+{
+ bench.name(strprintf("%s using the '%s' SHA256 implementation", __func__, SHA256AutoDetect(sha256_implementation::USE_SSE4)));
+ uint8_t hash[CSHA256::OUTPUT_SIZE];
+ std::vector<uint8_t> in(BUFFER_SIZE,0);
+ bench.batch(in.size()).unit("byte").run([&] {
+ CSHA256().Write(in.data(), in.size()).Finalize(hash);
+ });
+ SHA256AutoDetect();
+}
+
+static void SHA256_AVX2(benchmark::Bench& bench)
+{
+ bench.name(strprintf("%s using the '%s' SHA256 implementation", __func__, SHA256AutoDetect(sha256_implementation::USE_SSE4_AND_AVX2)));
+ uint8_t hash[CSHA256::OUTPUT_SIZE];
+ std::vector<uint8_t> in(BUFFER_SIZE,0);
+ bench.batch(in.size()).unit("byte").run([&] {
+ CSHA256().Write(in.data(), in.size()).Finalize(hash);
+ });
+ SHA256AutoDetect();
+}
+
+static void SHA256_SHANI(benchmark::Bench& bench)
+{
+ bench.name(strprintf("%s using the '%s' SHA256 implementation", __func__, SHA256AutoDetect(sha256_implementation::USE_SSE4_AND_SHANI)));
+ uint8_t hash[CSHA256::OUTPUT_SIZE];
+ std::vector<uint8_t> in(BUFFER_SIZE,0);
+ bench.batch(in.size()).unit("byte").run([&] {
+ CSHA256().Write(in.data(), in.size()).Finalize(hash);
+ });
+ SHA256AutoDetect();
}
static void SHA3_256_1M(benchmark::Bench& bench)
@@ -54,22 +90,92 @@ static void SHA3_256_1M(benchmark::Bench& bench)
});
}
-static void SHA256_32b(benchmark::Bench& bench)
+static void SHA256_32b_STANDARD(benchmark::Bench& bench)
+{
+ bench.name(strprintf("%s using the '%s' SHA256 implementation", __func__, SHA256AutoDetect(sha256_implementation::STANDARD)));
+ std::vector<uint8_t> in(32,0);
+ bench.batch(in.size()).unit("byte").run([&] {
+ CSHA256()
+ .Write(in.data(), in.size())
+ .Finalize(in.data());
+ });
+ SHA256AutoDetect();
+}
+
+static void SHA256_32b_SSE4(benchmark::Bench& bench)
+{
+ bench.name(strprintf("%s using the '%s' SHA256 implementation", __func__, SHA256AutoDetect(sha256_implementation::USE_SSE4)));
+ std::vector<uint8_t> in(32,0);
+ bench.batch(in.size()).unit("byte").run([&] {
+ CSHA256()
+ .Write(in.data(), in.size())
+ .Finalize(in.data());
+ });
+ SHA256AutoDetect();
+}
+
+static void SHA256_32b_AVX2(benchmark::Bench& bench)
+{
+ bench.name(strprintf("%s using the '%s' SHA256 implementation", __func__, SHA256AutoDetect(sha256_implementation::USE_SSE4_AND_AVX2)));
+ std::vector<uint8_t> in(32,0);
+ bench.batch(in.size()).unit("byte").run([&] {
+ CSHA256()
+ .Write(in.data(), in.size())
+ .Finalize(in.data());
+ });
+ SHA256AutoDetect();
+}
+
+static void SHA256_32b_SHANI(benchmark::Bench& bench)
{
+ bench.name(strprintf("%s using the '%s' SHA256 implementation", __func__, SHA256AutoDetect(sha256_implementation::USE_SSE4_AND_SHANI)));
std::vector<uint8_t> in(32,0);
bench.batch(in.size()).unit("byte").run([&] {
CSHA256()
.Write(in.data(), in.size())
.Finalize(in.data());
});
+ SHA256AutoDetect();
+}
+
+static void SHA256D64_1024_STANDARD(benchmark::Bench& bench)
+{
+ bench.name(strprintf("%s using the '%s' SHA256 implementation", __func__, SHA256AutoDetect(sha256_implementation::STANDARD)));
+ std::vector<uint8_t> in(64 * 1024, 0);
+ bench.batch(in.size()).unit("byte").run([&] {
+ SHA256D64(in.data(), in.data(), 1024);
+ });
+ SHA256AutoDetect();
+}
+
+static void SHA256D64_1024_SSE4(benchmark::Bench& bench)
+{
+ bench.name(strprintf("%s using the '%s' SHA256 implementation", __func__, SHA256AutoDetect(sha256_implementation::USE_SSE4)));
+ std::vector<uint8_t> in(64 * 1024, 0);
+ bench.batch(in.size()).unit("byte").run([&] {
+ SHA256D64(in.data(), in.data(), 1024);
+ });
+ SHA256AutoDetect();
+}
+
+static void SHA256D64_1024_AVX2(benchmark::Bench& bench)
+{
+ bench.name(strprintf("%s using the '%s' SHA256 implementation", __func__, SHA256AutoDetect(sha256_implementation::USE_SSE4_AND_AVX2)));
+ std::vector<uint8_t> in(64 * 1024, 0);
+ bench.batch(in.size()).unit("byte").run([&] {
+ SHA256D64(in.data(), in.data(), 1024);
+ });
+ SHA256AutoDetect();
}
-static void SHA256D64_1024(benchmark::Bench& bench)
+static void SHA256D64_1024_SHANI(benchmark::Bench& bench)
{
+ bench.name(strprintf("%s using the '%s' SHA256 implementation", __func__, SHA256AutoDetect(sha256_implementation::USE_SSE4_AND_SHANI)));
std::vector<uint8_t> in(64 * 1024, 0);
bench.batch(in.size()).unit("byte").run([&] {
SHA256D64(in.data(), in.data(), 1024);
});
+ SHA256AutoDetect();
}
static void SHA512(benchmark::Bench& bench)
@@ -152,13 +258,22 @@ static void MuHashPrecompute(benchmark::Bench& bench)
BENCHMARK(BenchRIPEMD160, benchmark::PriorityLevel::HIGH);
BENCHMARK(SHA1, benchmark::PriorityLevel::HIGH);
-BENCHMARK(SHA256, benchmark::PriorityLevel::HIGH);
+BENCHMARK(SHA256_STANDARD, benchmark::PriorityLevel::HIGH);
+BENCHMARK(SHA256_SSE4, benchmark::PriorityLevel::HIGH);
+BENCHMARK(SHA256_AVX2, benchmark::PriorityLevel::HIGH);
+BENCHMARK(SHA256_SHANI, benchmark::PriorityLevel::HIGH);
BENCHMARK(SHA512, benchmark::PriorityLevel::HIGH);
BENCHMARK(SHA3_256_1M, benchmark::PriorityLevel::HIGH);
-BENCHMARK(SHA256_32b, benchmark::PriorityLevel::HIGH);
+BENCHMARK(SHA256_32b_STANDARD, benchmark::PriorityLevel::HIGH);
+BENCHMARK(SHA256_32b_SSE4, benchmark::PriorityLevel::HIGH);
+BENCHMARK(SHA256_32b_AVX2, benchmark::PriorityLevel::HIGH);
+BENCHMARK(SHA256_32b_SHANI, benchmark::PriorityLevel::HIGH);
BENCHMARK(SipHash_32b, benchmark::PriorityLevel::HIGH);
-BENCHMARK(SHA256D64_1024, benchmark::PriorityLevel::HIGH);
+BENCHMARK(SHA256D64_1024_STANDARD, benchmark::PriorityLevel::HIGH);
+BENCHMARK(SHA256D64_1024_SSE4, benchmark::PriorityLevel::HIGH);
+BENCHMARK(SHA256D64_1024_AVX2, benchmark::PriorityLevel::HIGH);
+BENCHMARK(SHA256D64_1024_SHANI, benchmark::PriorityLevel::HIGH);
BENCHMARK(FastRandom_32bit, benchmark::PriorityLevel::HIGH);
BENCHMARK(FastRandom_1bit, benchmark::PriorityLevel::HIGH);
diff --git a/src/bench/disconnected_transactions.cpp b/src/bench/disconnected_transactions.cpp
index d6f1590950..0a7344b248 100644
--- a/src/bench/disconnected_transactions.cpp
+++ b/src/bench/disconnected_transactions.cpp
@@ -98,7 +98,7 @@ static void AddAndRemoveDisconnectedBlockTransactionsAll(benchmark::Bench& bench
const auto chains{CreateBlocks(/*num_not_shared=*/1)};
assert(chains.num_shared == BLOCK_VTX_COUNT - 1);
- bench.minEpochIterations(10).run([&]() NO_THREAD_SAFETY_ANALYSIS {
+ bench.minEpochIterations(10).run([&]() {
Reorg(chains);
});
}
@@ -109,7 +109,7 @@ static void AddAndRemoveDisconnectedBlockTransactions90(benchmark::Bench& bench)
const auto chains{CreateBlocks(/*num_not_shared=*/BLOCK_VTX_COUNT_10PERCENT)};
assert(chains.num_shared == BLOCK_VTX_COUNT - BLOCK_VTX_COUNT_10PERCENT);
- bench.minEpochIterations(10).run([&]() NO_THREAD_SAFETY_ANALYSIS {
+ bench.minEpochIterations(10).run([&]() {
Reorg(chains);
});
}
@@ -120,7 +120,7 @@ static void AddAndRemoveDisconnectedBlockTransactions10(benchmark::Bench& bench)
const auto chains{CreateBlocks(/*num_not_shared=*/BLOCK_VTX_COUNT - BLOCK_VTX_COUNT_10PERCENT)};
assert(chains.num_shared == BLOCK_VTX_COUNT_10PERCENT);
- bench.minEpochIterations(10).run([&]() NO_THREAD_SAFETY_ANALYSIS {
+ bench.minEpochIterations(10).run([&]() {
Reorg(chains);
});
}
diff --git a/src/bench/wallet_create_tx.cpp b/src/bench/wallet_create_tx.cpp
index 5e5bc76fd2..160534b63c 100644
--- a/src/bench/wallet_create_tx.cpp
+++ b/src/bench/wallet_create_tx.cpp
@@ -70,7 +70,7 @@ void generateFakeBlock(const CChainParams& params,
// notify wallet
const auto& pindex = WITH_LOCK(::cs_main, return context.chainman->ActiveChain().Tip());
- wallet.blockConnected(kernel::MakeBlockInfo(pindex, &block));
+ wallet.blockConnected(ChainstateRole::NORMAL, kernel::MakeBlockInfo(pindex, &block));
}
struct PreSelectInputs {