Skip to content

Commit

Permalink
Preparation for #1.4.0 (#30)
Browse files Browse the repository at this point in the history
- Fixed CPU affinity on Windows for NUMA and CPUs with lot of cores
- Implemented per thread configurable Multihash mode (double, triple, quadruple, quintuple)
- Rebased from XMRig 2.4.4
  • Loading branch information
Bendr0id authored Jan 19, 2018
1 parent 5f8ea98 commit acf27e9
Show file tree
Hide file tree
Showing 41 changed files with 2,538 additions and 1,067 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/test/CMakeFiles
/test/*/CMakeFiles
/build
/CMakeLists.txt.user
/.idea
Expand All @@ -7,3 +9,4 @@
CMakeCache.txt
cmake_install.cmake
Makefile
cmake-build-release/
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.4.0
- Fixed CPU affinity on Windows for NUMA and CPUs with lot of cores
- Implemented per thread configurable Multihash mode (double, triple, quadruple, quintuple)
- Rebased from XMRig 2.4.4
# v1.3.2
- Added start xmrigDaemonr without config file and only CCServer/auth token as params needed #14
- Dashboard now uses servertime for calculation to avoid clock drifts and false offline detection
Expand Down
111 changes: 26 additions & 85 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
cmake_minimum_required(VERSION 2.8)
project(xmrig)

#set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_BUILD_TYPE Release)
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)

option(WITH_LIBCPUID "Use Libcpuid" ON)
option(WITH_AEON "CryptoNight-Lite support" ON)
Expand All @@ -13,57 +14,6 @@ option(WITH_CC_SERVER "CC Server" ON)
include (CheckIncludeFile)
include (cmake/cpu.cmake)


set(HEADERS
src/3rdparty/align.h
src/api/Api.h
src/api/ApiState.h
src/api/NetworkState.h
src/App.h
src/interfaces/IClientListener.h
src/interfaces/IJobResultListener.h
src/interfaces/ILogBackend.h
src/interfaces/IStrategy.h
src/interfaces/IStrategyListener.h
src/interfaces/IWorker.h
src/net/Client.h
src/net/Job.h
src/net/JobId.h
src/net/JobResult.h
src/net/Network.h
src/net/strategies/DonateStrategy.h
src/net/strategies/FailoverStrategy.h
src/net/strategies/SinglePoolStrategy.h
src/net/SubmitResult.h
src/version.h
src/workers/DoubleWorker.h
src/workers/Handle.h
src/workers/Hashrate.h
src/workers/SingleWorker.h
src/workers/Worker.h
src/workers/Workers.h
)

set(HEADERS_CRYPTO
src/crypto/c_blake256.h
src/crypto/c_groestl.h
src/crypto/c_jh.h
src/crypto/c_keccak.h
src/crypto/c_skein.h
src/crypto/CryptoNight.h
src/crypto/CryptoNight_test.h
src/crypto/groestl_tables.h
src/crypto/hash.h
src/crypto/skein_port.h
src/crypto/soft_aes.h
)

if (XMRIG_ARM)
set(HEADERS_CRYPTO "${HEADERS_CRYPTO}" src/crypto/CryptoNight_arm.h)
else()
set(HEADERS_CRYPTO "${HEADERS_CRYPTO}" src/crypto/CryptoNight_x86.h)
endif()

set(SOURCES
src/api/Api.cpp
src/api/ApiState.cpp
Expand All @@ -77,10 +27,9 @@ set(SOURCES
src/net/strategies/SinglePoolStrategy.cpp
src/net/SubmitResult.cpp
src/Summary.cpp
src/workers/DoubleWorker.cpp
src/workers/MultiWorker.cpp
src/workers/Handle.cpp
src/workers/Hashrate.cpp
src/workers/SingleWorker.cpp
src/workers/Worker.cpp
src/workers/Workers.cpp
src/xmrig.cpp
Expand All @@ -95,20 +44,6 @@ set(SOURCES_CRYPTO
src/crypto/CryptoNight.cpp
)

set(HEADERS_COMMON
src/interfaces/IConsoleListener.h
src/Console.h
src/Mem.h
src/Cpu.h
src/net/Url.h
src/Options.h
src/log/ConsoleLog.h
src/log/FileLog.h
src/log/Log.h
src/Platform.h
src/Summary.h
)

set(SOURCES_COMMON
src/Console.cpp
src/Mem.cpp
Expand Down Expand Up @@ -219,11 +154,6 @@ if (WITH_CC_SERVER)
message(FATAL_ERROR "microhttpd NOT found: use `-DWITH_CC=OFF` to build without CC Server support")
endif()

set(HEADERS_CC_SERVER
src/cc/CCServer.h
src/cc/Service.h
src/cc/Httpd.h)

set(SOURCES_CC_SERVER
src/cc/CCServer.cpp
src/cc/Service.cpp
Expand All @@ -234,18 +164,11 @@ if (WITH_CC_SERVER)
endif()

if (WITH_CC_CLIENT)
set(HEADERS_CC_CLIENT
src/cc/CCClient.h)

set(SOURCES_CC_CLIENT
src/cc/CCClient.cpp)
endif()

if (WITH_CC_SERVER OR WITH_CC_CLIENT)
set(HEADERS_CC_COMMON
src/cc/ControlCommand.h
src/cc/ClientStatus.h)

set(SOURCES_CC_COMMON
src/cc/ControlCommand.cpp
src/cc/ClientStatus.cpp)
Expand All @@ -257,13 +180,31 @@ include_directories(src)
include_directories(src/3rdparty)
include_directories(${UV_INCLUDE_DIR})

add_executable(xmrigMiner ${HEADERS} ${SOURCES} ${HEADERS_COMMON} ${SOURCES_COMMON} ${SOURCES_OS} ${SOURCES_CPUID} ${HEADERS_CRYPTO} ${SOURCES_CRYPTO} ${SOURCES_SYSLOG} ${HTTPD_SOURCES} ${SOURCES_CC_COMMON} ${HEADERS_CC_COMMON} ${SOURCES_CC_CLIENT} ${HEADERS_CC_CLIENT})
target_link_libraries(xmrigMiner ${UV_LIBRARIES} ${MHD_LIBRARY} ${EXTRA_LIBS} ${CPUID_LIB})
add_library(xmrig_common STATIC ${SOURCES_COMMON})
add_library(xmrig_os_dependencies STATIC ${SOURCES_OS} ${SOURCES_SYSLOG})
add_library(xmrig_cpuid STATIC ${SOURCES_CPUID})

if (WITH_CC_SERVER OR WITH_CC_CLIENT)
add_library(xmrig_cc_common STATIC ${SOURCES_CC_COMMON})
endif (WITH_CC_SERVER OR WITH_CC_CLIENT)

add_executable(xmrigMiner ${SOURCES} ${SOURCES_CRYPTO} ${HTTPD_SOURCES} ${SOURCES_CC_CLIENT} res/app.rc)

target_link_libraries(xmrigMiner xmrig_common xmrig_cpuid xmrig_os_dependencies
${UV_LIBRARIES} ${MHD_LIBRARY} ${EXTRA_LIBS} ${CPUID_LIB})

if (WITH_CC_CLIENT)
target_link_libraries(xmrigMiner xmrig_cc_common)
endif (WITH_CC_CLIENT)

add_executable(xmrigDaemon src/cc/XMRigd.cpp res/app.rc)

if (WITH_CC_SERVER AND MHD_FOUND)
add_executable(xmrigCCServer ${HEADERS_COMMON} ${SOURCES_COMMON} ${SOURCES_OS} ${SOURCES_CPUID} ${SOURCES_SYSLOG} ${SOURCES_CC_COMMON} ${HEADERS_CC_COMMON} ${SOURCES_CC_SERVER} ${HEADERS_CC_SERVER})
target_link_libraries(xmrigCCServer ${UV_LIBRARIES} ${MHD_LIBRARY} ${EXTRA_LIBS} ${CPUID_LIB})
add_executable(xmrigCCServer ${SOURCES_CC_SERVER} res/app.rc)
target_link_libraries(xmrigCCServer
xmrig_common xmrig_cpuid xmrig_os_dependencies xmrig_cc_common
${UV_LIBRARIES} ${MHD_LIBRARY} ${EXTRA_LIBS} ${CPUID_LIB})
set_target_properties(xmrigCCServer PROPERTIES COMPILE_FLAGS "-DXMRIG_CC_SERVER ${SHARED_FLAGS}")
endif()

add_subdirectory(test EXCLUDE_FROM_ALL)
52 changes: 38 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,13 @@ xmrigDaemon -o pool.minemonero.pro:5555 -u YOUR_WALLET -p x -k --cc-url=IP_OF_CC
-O, --userpass=U:P username:password pair for mining server
-u, --user=USERNAME username for mining server
-p, --pass=PASSWORD password for mining server
-t, --threads=N number of miner threads
-v, --av=N algorithm variation, 0 auto select
-t, --threads=N number of miner threads (0 enables automatic selection of optimal number of threads, default: 0)
-m, --multihash-factor=N number of hash blocks per thread to process at a time (0 enables automatic selection of optimal number of hash blocks, default: 0)
-A, --aesni=N selection of AES-NI mode (0 auto, 1 on, 2 off, default: 0)
-k, --keepalive send keepalived for prevent timeout (need pool support)
-r, --retries=N number of times to retry before switch to backup server (default: 5)
-R, --retry-pause=N time to pause between retries (default: 5)
--doublehash-thread-mask for av=2/4 only, limits doublehash to given threads (mask), (default: all threads)
--multihash-thread-mask for multihash-factor > 1 only, limits multihash to given threads (mask), (default: all threads)
--cpu-affinity set process affinity to CPU core(s), mask 0x3 for cores 0 and 1
--cpu-priority set process priority (0 idle, 2 normal to 5 highest)
--no-huge-pages disable huge pages support
Expand All @@ -135,33 +136,51 @@ xmrigDaemon -o pool.minemonero.pro:5555 -u YOUR_WALLET -p x -k --cc-url=IP_OF_CC
-l, --log-file=FILE log all output to a file
-h, --help display this help and exit
-V, --version output version information and exit
-v, --av=N DEPRECATED - algorithm variation, 0 auto select
--doublehash-thread-mask DEPRECATED - same as multihash-thread-mask
```

Also you can use configuration via config file, default **[config.json](https://github.com/Bendr0id/xmrigCC/wiki/Config-XMRigDaemon)**. You can load multiple config files and combine it with command line options.

## Algorithm variations
* `--av=1` For CPUs with hardware AES.
* `--av=2` Lower power mode (double hash) of `1`.
* `--av=3` Software AES implementation.
* `--av=4` Lower power mode (double hash) of `3`.
## Multihash (multihash-factor)
With this option it is possible to increase the number of hashblocks calculated by a single thread in each round.
Selecting multihash-factors greater than 1 increases the L3 cache demands relative to the multihash-factor.
E.g. at multihash-factor 2, each Cryptonight thread requires 4MB and each Cryptonight-lite thread requires 2 MB of L3 cache.
With multihash-factor 3, they need 6MB or 3MB respectively.

## Doublehash thread Mask (only for low power mode (av=2 and av=4))
With this option you can limit doublehash to the given threads (mask). This can significantly improve your hashrate by using unused l3 cache. The default is to run av2/av4 mode on all threads.
Setting multihash-factor to 0 will allow automatic detection of the optimal value.
Xmrig will then try to utilize as much of the L3 cache as possible for the selected number of threads.
If the threads parameter has been set to auto, Xmrig will detect the optimal number of threads first.
After that it finds the greatest possible multihash-factor.

### Multihash for low power operation
Depending the CPU and its L3 caches, it can make sense to replace multiple single hash threads with single multi-hash counterparts.
This change might come at the price of a minor drop in effective hash-rate, yet it will also reduce heat production and power consumption of the used CPU.

### Multihash for optimal CPU exploitation
In certain environments (e.g. vServer) the system running xmrig can have access to relatively large amounts of L3 cache, but may has access to only a few CPU cores.
In such cases, running xmrig with higher multihash-factors can lead to improvements.


## Multihash thread Mask (only for multihash-factor > 1)
With this option you can limit multihash to the given threads (mask).
This can significantly improve your hashrate by using unused l3 cache.
The default is to run the configured multihash-factor on all threads.


```
{
...
"av":2,
"doublehash-thread-mask":"0x5", // in binary -> 0101
"multihash-factor":2,
"multihash-thread-mask":"0x5", // in binary -> 0101
"threads": 4,
...
}
```
This will limit doublehash mode (av=2,av=4) to thread 0 and thread 2, thread 1 and thread 3 will run in single hashmode (av=1,av=3).
This will limit multihash mode (multihash-factor = 2) to thread 0 and thread 2, thread 1 and thread 3 will run in single hashmode.


## Common Issues
Expand Down Expand Up @@ -193,13 +212,18 @@ This will limit doublehash mode (av=2,av=4) to thread 0 and thread 2, thread 1 a


### CPU mining performance
Please note performance is highly dependent on system load. The numbers above are obtained on an idle system. Tasks heavily using a processor cache, such as video playback, can greatly degrade hashrate. Optimal number of threads depends on the size of the L3 cache of a processor, 1 thread requires 2 MB (Cryptonight) or 1MB (Cryptonigh-Lite) of cache.
Please note performance is highly dependent on system load.
The numbers above are obtained on an idle system.
Tasks heavily using a processor cache, such as video playback, can greatly degrade hashrate.
Optimal number of threads depends on the size of the L3 cache of a processor, 1 thread requires 2 MB (Cryptonight) or 1MB (Cryptonigh-Lite) of cache.

### Maximum performance checklist
* Idle operating system.
* Do not exceed optimal thread count.
* Use modern CPUs with AES-NI instruction set.
* Try setup optimal cpu affinity.
* Try decreasing number of threads while increasing multihash-factor.
Allocate unused cores and L3 cache with the help of multihash-thread-mask.
* Enable fast memory (Large/Huge pages).

## Donations
Expand Down
12 changes: 0 additions & 12 deletions config_cc.json

This file was deleted.

20 changes: 6 additions & 14 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@
var clientId = $('#minerEditor').find('.form-group')["0"].dataset.value;
var clientConfig = $('#config').val();

setClientConfig(clientId, clientConfig, false);
setClientConfig(clientId, clientConfig);
});

$('#multiMinerEditorReplace').click(function(event) {
Expand All @@ -406,7 +406,7 @@
jsonClientConfig = JSON.stringify(jsonClientConfig,undefined, 2);
jsonClientConfig = jsonClientConfig.replace(new RegExp(search.trim(), 'g'), replacement.trim()).trim();

setClientConfig(clientId, jsonClientConfig, true);
setClientConfig(clientId, jsonClientConfig);
},
error: function (data) {
setError('<strong>Unable to fetch ' + clientId + '_config.json</strong> - Please make sure that you pulled the config before!');
Expand Down Expand Up @@ -471,7 +471,7 @@
tooltip += (row.client_status.hugepages_enabled ? "enabled" : "disabled");
tooltip += '\n';
tooltip += "Used Threads: " + row.client_status.current_threads;
tooltip += (row.client_status.double_hash_mode ? " [double hash mode]" :"");
tooltip += (row.client_status.hash_factor > 1 ? " [" + row.client_status.hash_factor + "x multi hash mode]" :"");
tooltip += '\n';
tooltip += "Client IP: " + row.client_status.external_ip;
tooltip += '\n';
Expand Down Expand Up @@ -531,25 +531,17 @@
}, 10000);
}

function setClientConfig(clientId, clientConfig, isMultiConfigEdit) {
function setClientConfig(clientId, clientConfig) {
$.ajax({
url: "/admin/setClientConfig?clientId=" + clientId,
type: 'POST',
dataType: "text",
data: clientConfig,
success: function(data){
if (isMultiConfigEdit) {
setSuccess('<strong>Successfully updated configs for the selected miners</strong> - You need push the config to the miners to apply the config.');
} else {
setSuccess('<strong>Successfully updated config for: ' + clientId + '</strong> - You need push the config to the miner to apply the config.');
}
setSuccess('<strong>Successfully updated config for: ' + clientId + '</strong> - You need push the config to the miner to apply the config.');
},
error: function (data) {
if (isMultiConfigEdit) {
setError('<strong>Failed to update configs for the selected miners</strong> \nError:' + JSON.stringify(data,undefined, 2));
} else {
setError('<strong>Failed to update config for: ' + clientId + '</strong> \nError: ' + JSON.stringify(data,undefined, 2));
}
setError('<strong>Failed to update config for: ' + clientId + '</strong> \nError: ' + JSON.stringify(data,undefined, 2));
}
});
}
Expand Down
4 changes: 3 additions & 1 deletion src/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ App::App(int argc, char **argv) :
m_self = this;

Cpu::init();

m_options = Options::parse(argc, argv);
if (!m_options) {
return;
Expand Down Expand Up @@ -137,12 +138,13 @@ int App::start()

background();

if (!CryptoNight::init(m_options->algo(), m_options->algoVariant())) {
if (!CryptoNight::init(m_options->algo(), m_options->aesni())) {
LOG_ERR("\"%s\" hash self-test failed.", m_options->algoName());
return EINVAL;
}

Mem::allocate(m_options);

Summary::print();

# ifndef XMRIG_NO_API
Expand Down
Loading

0 comments on commit acf27e9

Please sign in to comment.