diff --git a/index.html b/index.html index 49d82dd1..2c6d5613 100644 --- a/index.html +++ b/index.html @@ -567,7 +567,8 @@ tooltip += '\n'; tooltip += "CPU Cache L2/L3: " + (row.client_status.cpu_l2 / 1024) + " MB/"+ (row.client_status.cpu_l3 / 1024) + " MB"; tooltip += '\n'; - tooltip += "Huge Pages: " + (row.client_status.hugepages_available ? " available" : " unavailable"); + tooltip += "Huge Pages: " + (row.client_status.hugepages_available ? " available, " : " unavailable, "); + tooltip += (row.client_status.hugepages_enabled ? "enabled (" + row.client_status.total_hugepages + "/" + row.client_status.total_pages + ")" : "disabled"); tooltip += '\n'; tooltip += "Used Threads: " + row.client_status.current_threads; tooltip += (row.client_status.hash_factor > 1 ? " [" + row.client_status.hash_factor + "x multi hash mode]" :""); diff --git a/src/Mem.cpp b/src/Mem.cpp index 09cef4f2..2a9b1926 100644 --- a/src/Mem.cpp +++ b/src/Mem.cpp @@ -30,6 +30,8 @@ bool Mem::m_useHugePages = true; size_t Mem::m_hashFactor = 1; int Mem::m_flags = 0; +int Mem::m_totalPages = 0; +int Mem::m_totalHugepages = 0; Options::Algo Mem::m_algo = Options::ALGO_CRYPTONIGHT; Mem::ThreadBitSet Mem::m_multiHashThreadMask = Mem::ThreadBitSet(-1L); @@ -65,11 +67,17 @@ ScratchPadMem Mem::create(ScratchPad** scratchPads, int threadId) scratchPads[i] = scratchPad; } + m_totalPages += scratchPadMem.pages; + m_totalHugepages += scratchPadMem.hugePages; + return scratchPadMem; } void Mem::release(ScratchPad** scratchPads, ScratchPadMem& scratchPadMem, int threadId) { + m_totalPages -= scratchPadMem.pages; + m_totalHugepages -= scratchPadMem.hugePages; + release(scratchPadMem); for (size_t i = 0; i < getThreadHashFactor(threadId); ++i) { diff --git a/src/Mem.h b/src/Mem.h index 032d6662..790bdd7e 100644 --- a/src/Mem.h +++ b/src/Mem.h @@ -83,6 +83,10 @@ public: } static inline bool isHugepagesAvailable() { return (m_flags & HugepagesAvailable) != 0; } + static inline bool isHugepagesEnabled() { return (m_flags & HugepagesEnabled) != 0; } + + static inline int getTotalPages() { return m_totalPages; } + static inline int getTotalHugepages() { return m_totalHugepages; } private: static void allocate(ScratchPadMem& scratchPadMem, bool useHugePages); @@ -92,6 +96,8 @@ private: static bool m_useHugePages; static size_t m_hashFactor; static int m_flags; + static int m_totalPages; + static int m_totalHugepages; static Options::Algo m_algo; static ThreadBitSet m_multiHashThreadMask; }; diff --git a/src/Mem_unix.cpp b/src/Mem_unix.cpp index 619d9ed6..8acac2fa 100644 --- a/src/Mem_unix.cpp +++ b/src/Mem_unix.cpp @@ -59,10 +59,11 @@ void Mem::allocate(ScratchPadMem& scratchPadMem, bool useHugePages) return allocate(scratchPadMem, false); } - m_flags |= HugepagesAvailable; - scratchPadMem.hugePages = scratchPadMem.pages; + m_flags |= HugepagesAvailable; + m_flags |= HugepagesEnabled; + if (madvise(scratchPadMem.memory, scratchPadMem.size, MADV_RANDOM | MADV_WILLNEED) != 0) { LOG_ERR("madvise failed"); } diff --git a/src/Mem_win.cpp b/src/Mem_win.cpp index d6ee6ba5..b7a318d6 100644 --- a/src/Mem_win.cpp +++ b/src/Mem_win.cpp @@ -163,6 +163,8 @@ void Mem::allocate(ScratchPadMem& scratchPadMem, bool useHugePages) if (scratchPadMem.memory) { scratchPadMem.hugePages = scratchPadMem.pages; + m_flags |= HugepagesEnabled; + return; } diff --git a/src/cc/CCClient.cpp b/src/cc/CCClient.cpp index 4dc15b1b..596f2731 100644 --- a/src/cc/CCClient.cpp +++ b/src/cc/CCClient.cpp @@ -79,9 +79,7 @@ CCClient::CCClient(Options* options, uv_async_t* async) m_clientStatus.setCurrentAlgoName(m_options->algoName()); } - m_clientStatus.setHugepages(Mem::isHugepagesAvailable()); m_clientStatus.setHashFactor(Mem::hashFactor()); - m_clientStatus.setVersion(Version::string()); m_clientStatus.setCpuBrand(Cpu::brand()); m_clientStatus.setCpuAES(Cpu::hasAES()); @@ -134,6 +132,11 @@ void CCClient::updateNetworkState(const NetworkState& network) m_self->m_clientStatus.setSharesTotal(network.accepted + network.rejected); m_self->m_clientStatus.setHashesTotal(network.total); m_self->m_clientStatus.setAvgTime(network.avgTime()); + + m_self->m_clientStatus.setHugepagesEnabled(Mem::isHugepagesEnabled()); + m_self->m_clientStatus.setHugepages(Mem::isHugepagesAvailable()); + m_self->m_clientStatus.setTotalPages(Mem::getTotalPages()); + m_self->m_clientStatus.setTotalHugepages(Mem::getTotalHugepages()); m_self->m_clientStatus.setCurrentPowVariantName(getPowVariantName(network.powVariant)); uv_mutex_unlock(&m_mutex); diff --git a/src/cc/ClientStatus.cpp b/src/cc/ClientStatus.cpp index 76724c66..1a040907 100644 --- a/src/cc/ClientStatus.cpp +++ b/src/cc/ClientStatus.cpp @@ -34,13 +34,16 @@ ClientStatus::ClientStatus() : m_currentStatus(Status::PAUSED), m_hasHugepages(false), + m_isHugepagesEnabled(false), m_isCpuX64(false), m_hasCpuAES(false), - m_hashFactor(1), m_hashrateShort(0), m_hashrateMedium(0), m_hashrateLong(0), m_hashrateHighest(0), + m_hashFactor(1), + m_totalPages(0), + m_totalHugepages(0), m_currentThreads(0), m_cpuSockets(0), m_cpuCores(0), @@ -157,14 +160,14 @@ void ClientStatus::setHugepages(bool hasHugepages) m_hasHugepages = hasHugepages; } -int ClientStatus::getHashFactor() const +bool ClientStatus::isHugepagesEnabled() const { - return m_hashFactor; + return m_isHugepagesEnabled; } -void ClientStatus::setHashFactor(int hashFactor) +void ClientStatus::setHugepagesEnabled(bool hugepagesEnabled) { - m_hashFactor = hashFactor; + m_isHugepagesEnabled = hugepagesEnabled; } bool ClientStatus::isCpuX64() const @@ -227,6 +230,36 @@ double ClientStatus::getHashrateHighest() const return m_hashrateHighest; } +int ClientStatus::getHashFactor() const +{ + return m_hashFactor; +} + +void ClientStatus::setHashFactor(int hashFactor) +{ + m_hashFactor = hashFactor; +} + +int ClientStatus::getTotalPages() const +{ + return m_totalPages; +} + +void ClientStatus::setTotalPages(int totalPages) +{ + m_totalPages = totalPages; +} + +int ClientStatus::getTotalHugepages() const +{ + return m_totalHugepages; +} + +void ClientStatus::setTotalHugepages(int totalHugepages) +{ + m_totalHugepages = totalHugepages; +} + int ClientStatus::getCurrentThreads() const { return m_currentThreads; @@ -389,8 +422,8 @@ bool ClientStatus::parseFromJson(const rapidjson::Document& document) m_hasHugepages = clientStatus["hugepages_available"].GetBool(); } - if (clientStatus.HasMember("hash_factor")) { - m_hashFactor = clientStatus["hash_factor"].GetInt(); + if (clientStatus.HasMember("hugepages_enabled")) { + m_isHugepagesEnabled = clientStatus["hugepages_enabled"].GetBool(); } if (clientStatus.HasMember("cpu_is_x64")) { @@ -417,6 +450,18 @@ bool ClientStatus::parseFromJson(const rapidjson::Document& document) m_hashrateHighest = clientStatus["hashrate_highest"].GetDouble(); } + if (clientStatus.HasMember("hash_factor")) { + m_hashFactor = clientStatus["hash_factor"].GetInt(); + } + + if (clientStatus.HasMember("total_pages")) { + m_totalPages = clientStatus["total_pages"].GetInt(); + } + + if (clientStatus.HasMember("total_hugepages")) { + m_totalHugepages = clientStatus["total_hugepages"].GetInt(); + } + if (clientStatus.HasMember("current_threads")) { m_currentThreads = clientStatus["current_threads"].GetInt(); } @@ -487,7 +532,7 @@ rapidjson::Value ClientStatus::toJson(rapidjson::MemoryPoolAllocator