RandomX: added performance profiler (for developers)

Also optimized Blake2b SSE4.1 code size to avoid code cache pollution.
This commit is contained in:
SChernykh 2020-09-12 23:07:52 +02:00
parent adf833b60a
commit a05393727c
19 changed files with 390 additions and 481 deletions

View file

@ -38,6 +38,7 @@
#include "base/kernel/Platform.h"
#include "base/net/stratum/Job.h"
#include "base/tools/Object.h"
#include "base/tools/Profiler.h"
#include "base/tools/Timer.h"
#include "core/config/Config.h"
#include "core/Controller.h"
@ -267,6 +268,44 @@ public:
h = "MH/s";
}
# ifdef XMRIG_FEATURE_PROFILING
ProfileScopeData* data[ProfileScopeData::MAX_DATA_COUNT];
const uint32_t n = std::min<uint32_t>(ProfileScopeData::s_dataCount, ProfileScopeData::MAX_DATA_COUNT);
memcpy(data, ProfileScopeData::s_data, n * sizeof(ProfileScopeData*));
std::sort(data, data + n, [](ProfileScopeData* a, ProfileScopeData* b) {
return strcmp(a->m_threadId, b->m_threadId) < 0;
});
for (uint32_t i = 0; i < n;)
{
uint32_t n1 = i;
while ((n1 < n) && (strcmp(data[i]->m_threadId, data[n1]->m_threadId) == 0)) {
++n1;
}
std::sort(data + i, data + n1, [](ProfileScopeData* a, ProfileScopeData* b) {
return a->m_totalCycles > b->m_totalCycles;
});
for (uint32_t j = i; j < n1; ++j) {
ProfileScopeData* p = data[j];
LOG_INFO("%s Thread %6s | %-30s | %7.3f%% | %9.0f ns",
Tags::profiler(),
p->m_threadId,
p->m_name,
p->m_totalCycles * 100.0 / data[i]->m_totalCycles,
p->m_totalCycles / p->m_totalSamples * 1e9 / ProfileScopeData::s_tscSpeed
);
}
LOG_INFO("%s --------------|--------------------------------|----------|-------------", Tags::profiler());
i = n1;
}
# endif
LOG_INFO("%s " WHITE_BOLD("speed") " 10s/60s/15m " CYAN_BOLD("%s") CYAN(" %s %s ") CYAN_BOLD("%s") " max " CYAN_BOLD("%s %s"),
Tags::miner(),
Hashrate::format(speed[0] * scale, num, sizeof(num) / 4),
@ -311,6 +350,10 @@ xmrig::Miner::Miner(Controller *controller)
Platform::setThreadPriority(std::min(priority + 1, 5));
}
# ifdef XMRIG_FEATURE_PROFILING
ProfileScopeData::Init();
# endif
# ifdef XMRIG_ALGO_RANDOMX
Rx::init(this);
# endif