From d048bf78673636bf2fd232993f47e3a9a237774f Mon Sep 17 00:00:00 2001 From: psychocrypt Date: Sat, 24 Aug 2019 22:33:49 +0200 Subject: [PATCH] fix useless mutex solve partly #2514 Remove a mutex which is not needed at all because all data are accessed from one thread only. --- xmrstak/misc/telemetry.cpp | 6 ------ xmrstak/misc/telemetry.hpp | 4 ---- 2 files changed, 10 deletions(-) diff --git a/xmrstak/misc/telemetry.cpp b/xmrstak/misc/telemetry.cpp index 75fb4f434..ea73e6281 100644 --- a/xmrstak/misc/telemetry.cpp +++ b/xmrstak/misc/telemetry.cpp @@ -23,7 +23,6 @@ #include "telemetry.hpp" #include "xmrstak/net/msgstruct.hpp" -#include "xmrstak/cpputil/read_write_lock.h" #include #include @@ -37,7 +36,6 @@ telemetry::telemetry(size_t iThd) ppHashCounts = new uint64_t*[iThd]; ppTimestamps = new uint64_t*[iThd]; iBucketTop = new uint32_t[iThd]; - mtx = new ::cpputil::RWLock[iThd]; for(size_t i = 0; i < iThd; i++) { @@ -58,7 +56,6 @@ double telemetry::calc_telemetry_data(size_t iLastMillisec, size_t iThread) uint64_t iLatestHashCnt = 0; bool bHaveFullSet = false; - mtx[iThread].ReadLock(); uint64_t iTimeNow = get_timestamp_ms(); //Start at 1, buckettop points to next empty @@ -84,7 +81,6 @@ double telemetry::calc_telemetry_data(size_t iLastMillisec, size_t iThread) iEarliestStamp = ppTimestamps[iThread][idx]; iEarliestHashCnt = ppHashCounts[iThread][idx]; } - mtx[iThread].UnLock(); if(!bHaveFullSet || iEarliestStamp == 0 || iLatestStamp == 0) return nan(""); @@ -103,13 +99,11 @@ double telemetry::calc_telemetry_data(size_t iLastMillisec, size_t iThread) void telemetry::push_perf_value(size_t iThd, uint64_t iHashCount, uint64_t iTimestamp) { - mtx[iThd].WriteLock(); size_t iTop = iBucketTop[iThd]; ppHashCounts[iThd][iTop] = iHashCount; ppTimestamps[iThd][iTop] = iTimestamp; iBucketTop[iThd] = (iTop + 1) & iBucketMask; - mtx[iThd].UnLock(); } } // namespace xmrstak diff --git a/xmrstak/misc/telemetry.hpp b/xmrstak/misc/telemetry.hpp index a7b77c287..fb87bcd32 100644 --- a/xmrstak/misc/telemetry.hpp +++ b/xmrstak/misc/telemetry.hpp @@ -1,10 +1,7 @@ #pragma once -#include "xmrstak/cpputil/read_write_lock.h" - #include #include -#include namespace xmrstak { @@ -17,7 +14,6 @@ class telemetry double calc_telemetry_data(size_t iLastMillisec, size_t iThread); private: - ::cpputil::RWLock* mtx; constexpr static size_t iBucketSize = 2 << 11; //Power of 2 to simplify calculations constexpr static size_t iBucketMask = iBucketSize - 1; uint32_t* iBucketTop;