Added possibility to set variant by proxy (#79)

Added fix for wrong cpu cache detection
This commit is contained in:
Ben Gräf 2018-03-28 12:40:33 +02:00 committed by GitHub
parent 6fa0cf7b14
commit d353d15be4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 1 deletions

View file

@ -59,7 +59,13 @@ void CpuImpl::initCommon()
m_l2_cache = data.l2_cache * (m_totalCores / 2) * m_sockets;
m_l2_exclusive = true;
}
else {
// Workaround for Intel Pentium Dual-Core, Core Duo, Core 2 Duo, Core 2 Quad and their Xeon homologue
// These processors have L2 cache shared by 2 cores.
else if (data.vendor == VENDOR_INTEL && data.ext_family == 0x06 && (data.ext_model == 0x0E || data.ext_model == 0x0F || data.ext_model == 0x17)) {
int l2_count_per_socket = m_totalCores > 1 ? m_totalCores / 2 : 1;
m_l2_cache = data.l2_cache > 0 ? data.l2_cache * l2_count_per_socket * m_sockets : 0;
}
else{
m_l2_cache = data.l2_cache > 0 ? data.l2_cache * m_totalCores * m_sockets : 0;
}

View file

@ -1005,4 +1005,9 @@ bool Options::parseCCUrl(const char* url)
return true;
}
void Options::setForcePowVersion(Options::PowVersion powVersion)
{
m_forcePowVersion = powVersion;
}

View file

@ -112,6 +112,8 @@ public:
const char *algoName() const;
void setForcePowVersion(PowVersion version);
private:
constexpr static uint16_t kDefaultCCPort = 3344;

View file

@ -27,6 +27,7 @@
#include <string.h>
#include <utility>
#include <uv.h>
#include <Options.h>
#include "interfaces/IClientListener.h"
#include "log/Log.h"
@ -200,6 +201,26 @@ bool Client::parseJob(const rapidjson::Value &params, int *code)
return false;
}
if (params.HasMember("variant")) {
int variantFromProxy = params["variant"].GetInt();
if (Options::i()->forcePowVersion() == Options::POW_AUTODETECT) {
switch (variantFromProxy) {
case -1:
Options::i()->setForcePowVersion(Options::POW_AUTODETECT);
break;
case 0:
Options::i()->setForcePowVersion(Options::POW_V1);
break;
case 1:
Options::i()->setForcePowVersion(Options::POW_V2);
break;
default:
break;
}
}
}
if (m_job == job) {
if (!m_quiet) {
LOG_WARN("[%s:%u] duplicate job received, reconnect", m_url.host(), m_url.port());