Skip to content

Commit

Permalink
Merge pull request #2522 from psychocrypt/fix-uselessMutex
Browse files Browse the repository at this point in the history
fix useless mutex
  • Loading branch information
fireice-uk authored Aug 26, 2019
2 parents 8fe6928 + d048bf7 commit cd540b5
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 10 deletions.
6 changes: 0 additions & 6 deletions xmrstak/misc/telemetry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

#include "telemetry.hpp"
#include "xmrstak/net/msgstruct.hpp"
#include "xmrstak/cpputil/read_write_lock.h"

#include <chrono>
#include <cmath>
Expand All @@ -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++)
{
Expand All @@ -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
Expand All @@ -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("");
Expand All @@ -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
4 changes: 0 additions & 4 deletions xmrstak/misc/telemetry.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
#pragma once

#include "xmrstak/cpputil/read_write_lock.h"

#include <cstdint>
#include <cstring>
#include <mutex>

namespace xmrstak
{
Expand All @@ -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;
Expand Down

0 comments on commit cd540b5

Please sign in to comment.