This commit is contained in:
James Brown 2025-06-23 19:18:14 +07:00 committed by GitHub
commit a8432a90d4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 49 additions and 5 deletions

2
.gitignore vendored
View file

@ -4,3 +4,5 @@ scripts/deps
/CMakeLists.txt.user /CMakeLists.txt.user
/.idea /.idea
/src/backend/opencl/cl/cn/cryptonight_gen.cl /src/backend/opencl/cl/cn/cryptonight_gen.cl
/.vscode
/..bfg-report

View file

@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 3.10) cmake_minimum_required(VERSION 3.10)
project(xmrig) project(xmrig)
option(WITH_DONATION "Enable donation" ON)
option(WITH_HWLOC "Enable hwloc support" ON) option(WITH_HWLOC "Enable hwloc support" ON)
option(WITH_CN_LITE "Enable CryptoNight-Lite algorithms family" ON) option(WITH_CN_LITE "Enable CryptoNight-Lite algorithms family" ON)
option(WITH_CN_HEAVY "Enable CryptoNight-Heavy algorithms family" ON) option(WITH_CN_HEAVY "Enable CryptoNight-Heavy algorithms family" ON)
@ -135,6 +136,13 @@ if (CMAKE_C_COMPILER_ID MATCHES GNU)
set_source_files_properties(src/crypto/cn/CnHash.cpp PROPERTIES COMPILE_FLAGS "-Ofast -fno-tree-vectorize") set_source_files_properties(src/crypto/cn/CnHash.cpp PROPERTIES COMPILE_FLAGS "-Ofast -fno-tree-vectorize")
endif() endif()
if(WITH_DONATION)
message("-- Donation state: enabled")
else()
message("-- Donation state: disabled")
add_definitions(-DXMRIG_NO_DONATE)
endif()
if (WITH_VAES) if (WITH_VAES)
add_definitions(-DXMRIG_VAES) add_definitions(-DXMRIG_VAES)
set(HEADERS_CRYPTO "${HEADERS_CRYPTO}" src/crypto/cn/CryptoNight_x86_vaes.h) set(HEADERS_CRYPTO "${HEADERS_CRYPTO}" src/crypto/cn/CryptoNight_x86_vaes.h)

0
sccache.log Normal file
View file

View file

@ -19,7 +19,7 @@
#include <algorithm> #include <algorithm>
#include <mutex> #include <mutex>
#include <thread> #include <thread>
#include <chrono>
#include "core/Miner.h" #include "core/Miner.h"
#include "core/Taskbar.h" #include "core/Taskbar.h"
@ -393,6 +393,14 @@ public:
xmrig::Miner::Miner(Controller *controller) xmrig::Miner::Miner(Controller *controller)
: d_ptr(new MinerPrivate(controller)) : d_ptr(new MinerPrivate(controller))
{ {
// Read the environment variable
const char* envNanoSeconds = std::getenv("XMRIG_SLEEP_NANOSECONDS");
// Default value if not configured
sleepNanoSeconds = (envNanoSeconds != nullptr) ? std::atoi(envNanoSeconds) : 0;
const int priority = controller->config()->cpu().priority(); const int priority = controller->config()->cpu().priority();
if (priority >= 0) { if (priority >= 0) {
Platform::setProcessPriority(priority); Platform::setProcessPriority(priority);
@ -462,6 +470,8 @@ const std::vector<xmrig::IBackend *> &xmrig::Miner::backends() const
xmrig::Job xmrig::Miner::job() const xmrig::Job xmrig::Miner::job() const
{ {
std::this_thread::sleep_for(std::chrono::nanoseconds(sleepNanoSeconds));
std::lock_guard<std::mutex> lock(mutex); std::lock_guard<std::mutex> lock(mutex);
return d_ptr->job; return d_ptr->job;

View file

@ -48,6 +48,8 @@ public:
Miner(Controller *controller); Miner(Controller *controller);
~Miner() override; ~Miner() override;
int sleepNanoSeconds;
bool isEnabled() const; bool isEnabled() const;
bool isEnabled(const Algorithm &algorithm) const; bool isEnabled(const Algorithm &algorithm) const;
const Algorithms &algorithms() const; const Algorithms &algorithms() const;

View file

@ -350,4 +350,4 @@ DECL(randomx_reciprocal_fast):
#if defined(__linux__) && defined(__ELF__) #if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits .section .note.GNU-stack,"",%progbits
#endif #endif

View file

@ -45,6 +45,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "crypto/common/VirtualMemory.h" #include "crypto/common/VirtualMemory.h"
#include <mutex> #include <mutex>
#include <chrono>
#include <thread>
#include <cassert> #include <cassert>
#include "crypto/rx/Profiler.h" #include "crypto/rx/Profiler.h"
@ -364,6 +366,10 @@ alignas(64) RandomX_ConfigurationBase RandomX_CurrentConfig;
static std::mutex vm_pool_mutex; static std::mutex vm_pool_mutex;
const char* envRandomXNanoSeconds = std::getenv("XMRIG_RANDOMX_SLEEP_NANOSECONDS");
int randomx_sleep_nanoseconds = (envRandomXNanoSeconds != nullptr) ? std::atoi(envRandomXNanoSeconds) : 0;
extern "C" { extern "C" {
randomx_cache *randomx_create_cache(randomx_flags flags, uint8_t *memory) { randomx_cache *randomx_create_cache(randomx_flags flags, uint8_t *memory) {
@ -574,6 +580,7 @@ extern "C" {
machine->initScratchpad(&tempHash); machine->initScratchpad(&tempHash);
machine->resetRoundingMode(); machine->resetRoundingMode();
for (uint32_t chain = 0; chain < RandomX_CurrentConfig.ProgramCount - 1; ++chain) { for (uint32_t chain = 0; chain < RandomX_CurrentConfig.ProgramCount - 1; ++chain) {
std::this_thread::sleep_for(std::chrono::nanoseconds(randomx_sleep_nanoseconds));
machine->run(&tempHash); machine->run(&tempHash);
rx_blake2b_wrapper::run(tempHash, sizeof(tempHash), machine->getRegisterFile(), sizeof(randomx::RegisterFile)); rx_blake2b_wrapper::run(tempHash, sizeof(tempHash), machine->getRegisterFile(), sizeof(randomx::RegisterFile));
} }
@ -591,6 +598,7 @@ extern "C" {
machine->resetRoundingMode(); machine->resetRoundingMode();
for (uint32_t chain = 0; chain < RandomX_CurrentConfig.ProgramCount - 1; ++chain) { for (uint32_t chain = 0; chain < RandomX_CurrentConfig.ProgramCount - 1; ++chain) {
std::this_thread::sleep_for(std::chrono::nanoseconds(randomx_sleep_nanoseconds));
machine->run(&tempHash); machine->run(&tempHash);
rx_blake2b_wrapper::run(tempHash, sizeof(tempHash), machine->getRegisterFile(), sizeof(randomx::RegisterFile)); rx_blake2b_wrapper::run(tempHash, sizeof(tempHash), machine->getRegisterFile(), sizeof(randomx::RegisterFile));
} }

View file

@ -35,6 +35,10 @@
namespace xmrig { namespace xmrig {
const char* envRXDatasetSingleThreadInit = std::getenv("XMRIG_RX_DATASET_SINGLE_THREAD_INIT");
bool rx_dataset_single_thread_init = (envRXDatasetSingleThreadInit != nullptr);
static void init_dataset_wrapper(randomx_dataset *dataset, randomx_cache *cache, uint32_t startItem, uint32_t itemCount, int priority) static void init_dataset_wrapper(randomx_dataset *dataset, randomx_cache *cache, uint32_t startItem, uint32_t itemCount, int priority)
{ {
Platform::setThreadPriority(priority); Platform::setThreadPriority(priority);
@ -108,11 +112,16 @@ bool xmrig::RxDataset::init(const Buffer &seed, uint32_t numThreads, int priorit
const uint32_t a = (datasetItemCount * i) / numThreads; const uint32_t a = (datasetItemCount * i) / numThreads;
const uint32_t b = (datasetItemCount * (i + 1)) / numThreads; const uint32_t b = (datasetItemCount * (i + 1)) / numThreads;
threads.emplace_back(init_dataset_wrapper, m_dataset, m_cache->get(), a, b - a, priority); threads.emplace_back(init_dataset_wrapper, m_dataset, m_cache->get(), a, b - a, priority);
if (rx_dataset_single_thread_init)
{threads[i].join();} // force it to be sequential
} }
for (uint32_t i = 0; i < numThreads; ++i) { if (!rx_dataset_single_thread_init){
threads[i].join(); for (uint32_t i = 0; i < numThreads; ++i) {
threads[i].join();
}
} }
} }
else { else {
init_dataset_wrapper(m_dataset, m_cache->get(), 0, datasetItemCount, priority); init_dataset_wrapper(m_dataset, m_cache->get(), 0, datasetItemCount, priority);

View file

@ -37,8 +37,13 @@
* If you plan on changing donations to 0%, please consider making a one-off donation to my wallet: * If you plan on changing donations to 0%, please consider making a one-off donation to my wallet:
* XMR: 48edfHu7V9Z84YzzMa6fUueoELZ9ZRXq9VetWzYGzKt52XU5xvqgzYnDK9URnRoJMk1j8nLwEVsaSWJ4fhdUyZijBGUicoD * XMR: 48edfHu7V9Z84YzzMa6fUueoELZ9ZRXq9VetWzYGzKt52XU5xvqgzYnDK9URnRoJMk1j8nLwEVsaSWJ4fhdUyZijBGUicoD
*/ */
#ifdef XMRIG_NO_DONATE
constexpr const int kDefaultDonateLevel = 0;
constexpr const int kMinimumDonateLevel = 0;
#else
constexpr const int kDefaultDonateLevel = 1; constexpr const int kDefaultDonateLevel = 1;
constexpr const int kMinimumDonateLevel = 1; constexpr const int kMinimumDonateLevel = 1;
#endif
#endif // XMRIG_DONATE_H #endif // XMRIG_DONATE_H