Skip to content
Snippets Groups Projects
Unverified Commit 41cdbaff authored by fireice-uk's avatar fireice-uk Committed by GitHub
Browse files

Merge pull request #2387 from psychocrypt/topic-noDevPoolHashRate2

avoid hash rate drop during dev pool mining
parents 21c17963 50c7bb36
No related branches found
No related tags found
No related merge requests found
...@@ -172,7 +172,6 @@ void minethd::work_main() ...@@ -172,7 +172,6 @@ void minethd::work_main()
lck.release(); lck.release();
std::this_thread::yield(); std::this_thread::yield();
uint64_t iCount = 0;
cryptonight_ctx* cpu_ctx; cryptonight_ctx* cpu_ctx;
cpu_ctx = cpu::minethd::minethd_alloc_ctx(); cpu_ctx = cpu::minethd::minethd_alloc_ctx();
...@@ -288,10 +287,7 @@ void minethd::work_main() ...@@ -288,10 +287,7 @@ void minethd::work_main()
executor::inst()->push_event(ex_event("AMD Invalid Result", pGpuCtx->deviceIdx, oWork.iPoolId)); executor::inst()->push_event(ex_event("AMD Invalid Result", pGpuCtx->deviceIdx, oWork.iPoolId));
} }
iCount += pGpuCtx->rawIntensity; updateStats(pGpuCtx->rawIntensity, oWork.iPoolId);
uint64_t iStamp = get_timestamp_ms();
iHashCount.store(iCount, std::memory_order_relaxed);
iTimestamp.store(iStamp, std::memory_order_relaxed);
accRuntime += updateTimings(pGpuCtx, t0); accRuntime += updateTimings(pGpuCtx, t0);
......
...@@ -833,6 +833,7 @@ void minethd::multiway_work_main() ...@@ -833,6 +833,7 @@ void minethd::multiway_work_main()
cryptonight_ctx* ctx[MAX_N]; cryptonight_ctx* ctx[MAX_N];
uint64_t iCount = 0; uint64_t iCount = 0;
uint64_t iLastCount = 0;
uint64_t* piHashVal[MAX_N]; uint64_t* piHashVal[MAX_N];
uint32_t* piNonce[MAX_N]; uint32_t* piNonce[MAX_N];
uint8_t bHashOut[MAX_N * 32]; uint8_t bHashOut[MAX_N * 32];
...@@ -915,9 +916,8 @@ void minethd::multiway_work_main() ...@@ -915,9 +916,8 @@ void minethd::multiway_work_main()
{ {
if((iCount++ & 0x7) == 0) //Store stats every 8*N hashes if((iCount++ & 0x7) == 0) //Store stats every 8*N hashes
{ {
uint64_t iStamp = get_timestamp_ms(); updateStats((iCount - iLastCount) * N, oWork.iPoolId);
iHashCount.store(iCount * N, std::memory_order_relaxed); iLastCount = iCount;
iTimestamp.store(iStamp, std::memory_order_relaxed);
} }
nonce_ctr -= N; nonce_ctr -= N;
......
#pragma once #pragma once
#include "xmrstak/backend/globalStates.hpp" #include "xmrstak/backend/globalStates.hpp"
#include "xmrstak/net/msgstruct.hpp"
#include <atomic> #include <atomic>
#include <climits> #include <climits>
...@@ -46,6 +47,29 @@ struct iBackend ...@@ -46,6 +47,29 @@ struct iBackend
std::atomic<uint64_t> iTimestamp; std::atomic<uint64_t> iTimestamp;
uint32_t iThreadNo; uint32_t iThreadNo;
BackendType backendType = UNKNOWN; BackendType backendType = UNKNOWN;
uint64_t iLastStamp = get_timestamp_ms();
double avgHashPerMsec = 0.0;
void updateStats(uint64_t numNewHashes, size_t poolId)
{
uint64_t iStamp = get_timestamp_ms();
double timeDiff = static_cast<double>(iStamp - iLastStamp);
iLastStamp = iStamp;
if(poolId == 0)
{
// if dev pool is active interpolate the number of shares (avoid hash rate drops)
numNewHashes = static_cast<uint64_t>(avgHashPerMsec * timeDiff);
}
else
{
const double hashRatePerMs = static_cast<double>(numNewHashes) / timeDiff;
constexpr double averagingBias = 0.1;
avgHashPerMsec = avgHashPerMsec * (1.0 - averagingBias) + hashRatePerMs * averagingBias;
}
iHashCount.fetch_add(numNewHashes, std::memory_order_relaxed);
iTimestamp.store(iStamp, std::memory_order_relaxed);
}
iBackend() : iBackend() :
iHashCount(0), iHashCount(0),
......
...@@ -198,7 +198,6 @@ void minethd::work_main() ...@@ -198,7 +198,6 @@ void minethd::work_main()
// wait until all NVIDIA devices are initialized // wait until all NVIDIA devices are initialized
thread_work_guard.wait(); thread_work_guard.wait();
uint64_t iCount = 0;
cryptonight_ctx* cpu_ctx; cryptonight_ctx* cpu_ctx;
cpu_ctx = cpu::minethd::minethd_alloc_ctx(); cpu_ctx = cpu::minethd::minethd_alloc_ctx();
...@@ -297,13 +296,8 @@ void minethd::work_main() ...@@ -297,13 +296,8 @@ void minethd::work_main()
executor::inst()->push_event(ex_event("NVIDIA Invalid Result", ctx.device_id, oWork.iPoolId)); executor::inst()->push_event(ex_event("NVIDIA Invalid Result", ctx.device_id, oWork.iPoolId));
} }
iCount += h_per_round;
iNonce += h_per_round; iNonce += h_per_round;
updateStats(h_per_round, oWork.iPoolId);
using namespace std::chrono;
uint64_t iStamp = get_timestamp_ms();
iHashCount.store(iCount, std::memory_order_relaxed);
iTimestamp.store(iStamp, std::memory_order_relaxed);
std::this_thread::yield(); std::this_thread::yield();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment