From 06eed3391273447106683ba0b62275da00de850c Mon Sep 17 00:00:00 2001 From: TheRealGioviok <64363733+TheRealGioviok@users.noreply.github.com> Date: Wed, 8 Jul 2026 13:37:18 +0200 Subject: [PATCH 1/3] Bench: 12898941 --- src/tt.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/tt.cpp b/src/tt.cpp index f136d785..3b852f50 100644 --- a/src/tt.cpp +++ b/src/tt.cpp @@ -173,23 +173,24 @@ void TT::resize(size_t mb, usize thread_count) { } void TT::clear(usize thread_count) { + usize max_threads = std::min(thread_count, usize(16)); + std::vector threads; - threads.reserve(thread_count); - for (usize t = 0; t < thread_count; ++t) { - threads.emplace_back([this, t, thread_count]() { - size_t start = (m_size * t) / thread_count; - size_t end = (m_size * (t + 1)) / thread_count; - if (t == thread_count - 1) { + threads.reserve(max_threads); + + for (usize t = 0; t < max_threads; ++t) { + threads.emplace_back([this, t, max_threads]() { + usize start = (m_size * t) / max_threads; + usize end = (m_size * (t + 1)) / max_threads; + if (t == max_threads - 1) { end = m_size; } - for (size_t i = start; i < end; ++i) { - m_clusters[i].data[0].store(0, std::memory_order_relaxed); - m_clusters[i].data[1].store(0, std::memory_order_relaxed); - m_clusters[i].data[2].store(0, std::memory_order_relaxed); - m_clusters[i].data[3].store(0, std::memory_order_relaxed); - } + + usize chunk_bytes = (end - start) * sizeof(Cluster); + std::memset(&m_clusters[start], 0, chunk_bytes); }); } + for (auto& thread : threads) { thread.join(); } From e74f971d6392942879c6c901fcd5d867d00403c0 Mon Sep 17 00:00:00 2001 From: TheRealGioviok <425gioviok@gmail.com> Date: Sun, 12 Jul 2026 01:19:26 +0200 Subject: [PATCH 2/3] Bench: 12898941 --- src/tt.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tt.cpp b/src/tt.cpp index 3b852f50..91448f8f 100644 --- a/src/tt.cpp +++ b/src/tt.cpp @@ -186,7 +186,7 @@ void TT::clear(usize thread_count) { end = m_size; } - usize chunk_bytes = (end - start) * sizeof(Cluster); + usize chunk_bytes = (end - start) * sizeof(TTCluster); std::memset(&m_clusters[start], 0, chunk_bytes); }); } From 155fc44d7dc360f9c632e5efbe7cc4ed22e66085 Mon Sep 17 00:00:00 2001 From: TheRealGioviok <425gioviok@gmail.com> Date: Sun, 12 Jul 2026 01:28:28 +0200 Subject: [PATCH 3/3] Bench: 12898941 --- src/tt.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tt.cpp b/src/tt.cpp index 91448f8f..c298d075 100644 --- a/src/tt.cpp +++ b/src/tt.cpp @@ -173,8 +173,8 @@ void TT::resize(size_t mb, usize thread_count) { } void TT::clear(usize thread_count) { - usize max_threads = std::min(thread_count, usize(16)); - + usize max_threads = std::max(thread_count, usize(1)); + std::vector threads; threads.reserve(max_threads);