More precise hashrate calculation
- Use only steady timestamp counters to guarantee correctness - CPU backend: directly measure total hashrate using raw hash counters from each thread; update data more often on ARM CPUs because they're slower - GPU backends: directly measure total hashrate too, but use interpolator with 4 second lag to fix variance from batches of hashes Total hashrate is now measured directly (realtime for CPU, 4 seconds lag for GPU), so it might differ a bit from the sum of all thread hashrates because data points are taken at different moments in time. Overhead is reduced a lot since it doesn't have to go through all threads to calculate max total hashrate on every timer tick (2 times a second).
This commit is contained in:
parent
0a2fe5caa7
commit
3fbf2ac3d4
17 changed files with 192 additions and 39 deletions
|
@ -29,6 +29,7 @@
|
|||
#include "backend/common/Workers.h"
|
||||
#include "backend/cpu/CpuWorker.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/tools/Chrono.h"
|
||||
#include "base/tools/Object.h"
|
||||
|
||||
|
||||
|
@ -142,13 +143,20 @@ void xmrig::Workers<T>::tick(uint64_t)
|
|||
return;
|
||||
}
|
||||
|
||||
uint64_t totalHashCount = 0;
|
||||
|
||||
for (Thread<T> *handle : m_workers) {
|
||||
if (handle->worker()) {
|
||||
uint64_t hashCount, timeStamp;
|
||||
handle->worker()->getHashrateData(hashCount, timeStamp);
|
||||
d_ptr->hashrate->add(handle->id(), hashCount, timeStamp);
|
||||
d_ptr->hashrate->add(handle->id() + 1, hashCount, timeStamp);
|
||||
totalHashCount += handle->worker()->rawHashes();
|
||||
}
|
||||
}
|
||||
|
||||
if (totalHashCount > 0) {
|
||||
d_ptr->hashrate->add(0, totalHashCount, Chrono::steadyMSecs());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue