Skip to content

Commit

Permalink
Merged upstream.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Schiller committed Jan 25, 2018
2 parents 7814bdd + 631fd75 commit 496ddab
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 60 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v2.4.4
- Added libmicrohttpd version to --version output.
- Fixed bug in singal handler, in some cases miner wasn't shutdown properly.
- Fixed recent MSVC 2017 version detection.
- [#279](https://github.com/xmrig/xmrig/pull/279) Fixed build on some macOS versions.

# v2.4.3.1
- Removed `donate-level`.

Expand Down
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 2.8)
project(xmrig)

option(WITH_LIBCPUID "Use Libcpuid" ON)
Expand Down Expand Up @@ -193,6 +193,7 @@ if (WITH_HTTPD)
message(FATAL_ERROR "microhttpd NOT found: use `-DWITH_HTTPD=OFF` to build without http deamon support")
endif()
else()
set(MHD_LIBRARY "")
add_definitions(/DXMRIG_NO_HTTPD)
add_definitions(/DXMRIG_NO_API)
endif()
Expand Down
59 changes: 31 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# XMRig
XMRig is high performance Monero (XMR) CPU miner, with the official full Windows support.
Originally based on cpuminer-multi with heavy optimizations/rewrites and removing a lot of legacy code, since version 1.0.0 complete rewritten from scratch on C++.
XMRig is a high performance Monero (XMR) CPU miner, with official support for Windows.
Originally based on cpuminer-multi with heavy optimizations/rewrites and removing a lot of legacy code, since version 1.0.0 completely rewritten from scratch on C++.

* This is the **CPU-mining** version, there is also a [NVIDIA GPU version](https://github.com/xmrig/xmrig-nvidia) and [AMD GPU version]( https://github.com/xmrig/xmrig-amd).
* [Roadmap](https://github.com/xmrig/xmrig/issues/106) for next releases.
Expand Down Expand Up @@ -50,30 +50,33 @@ For failover you can add multiple pools, maximum count not limited.

### Options
```
-a, --algo=ALGO cryptonight (default) or cryptonight-lite
-o, --url=URL URL of mining server
-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
-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)
--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
--no-color disable colored output
--user-agent set custom user-agent string for pool
-B, --background run the miner in the background
-c, --config=FILE load a JSON-format configuration file
-l, --log-file=FILE log all output to a file
--max-cpu-usage=N maximum CPU usage for automatic threads mode (default 75)
--safe safe adjust threads and av settings for current CPU
--nicehash enable nicehash support
--print-time=N print hashrate report every N seconds
-h, --help display this help and exit
-V, --version output version information and exit
-a, --algo=ALGO cryptonight (default) or cryptonight-lite
-o, --url=URL URL of mining server
-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
-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)
--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
--no-color disable colored output
--user-agent set custom user-agent string for pool
-B, --background run the miner in the background
-c, --config=FILE load a JSON-format configuration file
-l, --log-file=FILE log all output to a file
--max-cpu-usage=N maximum CPU usage for automatic threads mode (default 75)
--safe safe adjust threads and av settings for current CPU
--nicehash enable nicehash/xmrig-proxy support
--print-time=N print hashrate report every N seconds
--api-port=N port for the miner API
--api-access-token=T access token for API
--api-worker-id=ID custom worker-id for API
-h, --help display this help and exit
-V, --version output version information and exit
```

Also you can use configuration via config file, default **config.json**. You can load multiple config files and combine it with command line options.
Expand All @@ -88,7 +91,7 @@ Since version 0.8.0.
## Common Issues
### HUGE PAGES unavailable
* Run XMRig as Administrator.
* Since version 0.8.0 XMRig automatically enable SeLockMemoryPrivilege for current user, but reboot or sign out still required. [Manual instruction](https://msdn.microsoft.com/en-gb/library/ms190730.aspx).
* Since version 0.8.0 XMRig automatically enables SeLockMemoryPrivilege for current user, but reboot or sign out still required. [Manual instruction](https://msdn.microsoft.com/en-gb/library/ms190730.aspx).

## Other information
* No HTTP support, only stratum protocol support.
Expand All @@ -104,7 +107,7 @@ Please note performance is highly dependent on system load. The numbers above ar
### Maximum performance checklist
* Idle operating system.
* Do not exceed optimal thread count.
* Use modern CPUs with AES-NI instructuon set.
* Use modern CPUs with AES-NI instruction set.
* Try setup optimal cpu affinity.
* Enable fast memory (Large/Huge pages).

Expand Down
44 changes: 31 additions & 13 deletions src/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ App::App(int argc, char **argv) :

m_network = new Network(m_options);

uv_signal_init(uv_default_loop(), &m_signal);
uv_signal_init(uv_default_loop(), &m_sigHUP);
uv_signal_init(uv_default_loop(), &m_sigINT);
uv_signal_init(uv_default_loop(), &m_sigTERM);
}


Expand All @@ -111,12 +113,12 @@ App::~App()
int App::exec()
{
if (!m_options) {
return 0;
return 2;
}

uv_signal_start(&m_signal, App::onSignal, SIGHUP);
uv_signal_start(&m_signal, App::onSignal, SIGTERM);
uv_signal_start(&m_signal, App::onSignal, SIGINT);
uv_signal_start(&m_sigHUP, App::onSignal, SIGHUP);
uv_signal_start(&m_sigINT, App::onSignal, SIGINT);
uv_signal_start(&m_sigTERM, App::onSignal, SIGTERM);

background();

Expand All @@ -128,6 +130,13 @@ int App::exec()
Mem::allocate(m_options->algo(), m_options->threads(), m_options->doubleHash(), m_options->hugePages());
Summary::print();

if (m_options->dryRun()) {
LOG_NOTICE("OK");
release();

return 0;
}

# ifndef XMRIG_NO_API
Api::start();
# endif
Expand All @@ -144,12 +153,7 @@ int App::exec()
const int r = uv_run(uv_default_loop(), UV_RUN_DEFAULT);
uv_loop_close(uv_default_loop());

delete m_network;

Options::release();
Mem::release();
Platform::release();

release();
return r;
}

Expand All @@ -164,8 +168,10 @@ void App::onConsoleCommand(char command)

case 'p':
case 'P':
LOG_INFO(m_options->colors() ? "\x1B[01;33mpaused\x1B[0m, press \x1B[01;35mr\x1B[0m to resume" : "paused, press 'r' to resume");
Workers::setEnabled(false);
if (Workers::isEnabled()) {
LOG_INFO(m_options->colors() ? "\x1B[01;33mpaused\x1B[0m, press \x1B[01;35mr\x1B[0m to resume" : "paused, press 'r' to resume");
Workers::setEnabled(false);
}
break;

case 'r':
Expand Down Expand Up @@ -196,6 +202,18 @@ void App::close()
}


void App::release()
{
if (m_network) {
delete m_network;
}

Options::release();
Mem::release();
Platform::release();
}


void App::onSignal(uv_signal_t *handle, int signum)
{
switch (signum)
Expand Down
5 changes: 4 additions & 1 deletion src/App.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class App : public IConsoleListener
private:
void background();
void close();
void release();

static void onSignal(uv_signal_t *handle, int signum);

Expand All @@ -60,7 +61,9 @@ class App : public IConsoleListener
Httpd *m_httpd;
Network *m_network;
Options *m_options;
uv_signal_t m_signal;
uv_signal_t m_sigHUP;
uv_signal_t m_sigINT;
uv_signal_t m_sigTERM;
};


Expand Down
23 changes: 20 additions & 3 deletions src/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
#endif


#ifndef XMRIG_NO_HTTPD
# include <microhttpd.h>
#endif


#include "Cpu.h"
#include "net/Url.h"
#include "Options.h"
Expand Down Expand Up @@ -94,11 +99,15 @@ static char const short_options[] = "a:c:khBp:Px:r:R:s:t:T:o:u:O:v:Vl:S";

static struct option const options[] = {
{ "algo", 1, nullptr, 'a' },
{ "api-access-token", 1, nullptr, 4001 },
{ "api-port", 1, nullptr, 4000 },
{ "api-worker-id", 1, nullptr, 4002 },
{ "av", 1, nullptr, 'v' },
{ "background", 0, nullptr, 'B' },
{ "config", 1, nullptr, 'c' },
{ "cpu-affinity", 1, nullptr, 1020 },
{ "cpu-priority", 1, nullptr, 1021 },
{ "dry-run", 0, nullptr, 5000 },
{ "help", 0, nullptr, 'h' },
{ "keepalive", 0, nullptr ,'k' },
{ "log-file", 1, nullptr, 'l' },
Expand All @@ -118,9 +127,6 @@ static struct option const options[] = {
{ "user-agent", 1, nullptr, 1008 },
{ "userpass", 1, nullptr, 'O' },
{ "version", 0, nullptr, 'V' },
{ "api-port", 1, nullptr, 4000 },
{ "api-access-token", 1, nullptr, 4001 },
{ "api-worker-id", 1, nullptr, 4002 },
{ 0, 0, 0, 0 }
};

Expand All @@ -132,6 +138,7 @@ static struct option const config_options[] = {
{ "colors", 0, nullptr, 2000 },
{ "cpu-affinity", 1, nullptr, 1020 },
{ "cpu-priority", 1, nullptr, 1021 },
{ "dry-run", 0, nullptr, 5000 },
{ "huge-pages", 0, nullptr, 1009 },
{ "log-file", 1, nullptr, 'l' },
{ "max-cpu-usage", 1, nullptr, 1004 },
Expand Down Expand Up @@ -196,6 +203,7 @@ Options::Options(int argc, char **argv) :
m_background(false),
m_colors(true),
m_doubleHash(false),
m_dryRun(false),
m_hugePages(true),
m_ready(false),
m_safe(false),
Expand Down Expand Up @@ -373,6 +381,7 @@ bool Options::parseArg(int key, const char *arg)
case 'S': /* --syslog */
case 1005: /* --safe */
case 1006: /* --nicehash */
case 5000: /* --dry-run */
return parseBoolean(key, true);

case 1002: /* --no-color */
Expand Down Expand Up @@ -538,6 +547,10 @@ bool Options::parseBoolean(int key, bool enable)
m_colors = enable;
break;

case 5000: /* --dry-run */
m_dryRun = enable;
break;

default:
break;
}
Expand Down Expand Up @@ -651,6 +664,10 @@ void Options::showVersion()
"\n");

printf("\nlibuv/%s\n", uv_version_string());

# ifndef XMRIG_NO_HTTPD
printf("libmicrohttpd/%s\n", MHD_get_version());
# endif
}


Expand Down
2 changes: 2 additions & 0 deletions src/Options.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class Options
inline bool background() const { return m_background; }
inline bool colors() const { return m_colors; }
inline bool doubleHash() const { return m_doubleHash; }
inline bool dryRun() const { return m_dryRun; }
inline bool hugePages() const { return m_hugePages; }
inline bool syslog() const { return m_syslog; }
inline const char *apiToken() const { return m_apiToken; }
Expand Down Expand Up @@ -109,6 +110,7 @@ class Options
bool m_background;
bool m_colors;
bool m_doubleHash;
bool m_dryRun;
bool m_hugePages;
bool m_ready;
bool m_safe;
Expand Down
11 changes: 6 additions & 5 deletions src/Platform_mac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
*/


#include <stdio.h>
#include <stdlib.h>
#include <sys/resource.h>
#include <uv.h>
Expand All @@ -41,11 +42,11 @@ static inline char *createUserAgent()

char *buf = new char[max];

# ifdef XMRIG_NVIDIA_PROJECT
const int cudaVersion = cuda_get_runtime_version();
snprintf(buf, max, "%s/%s (Macintosh; Intel Mac OS X) libuv/%s CUDA/%d.%d clang/%d.%d.%d", APP_NAME, APP_VERSION, uv_version_string(), cudaVersion / 1000, cudaVersion % 100, __clang_major__, __clang_minor__, __clang_patchlevel__);
# else
snprintf(buf, max, "%s/%s (Macintosh; Intel Mac OS X) libuv/%s clang/%d.%d.%d", APP_NAME, APP_VERSION, uv_version_string(), __clang_major__, __clang_minor__, __clang_patchlevel__);
# ifdef XMRIG_NVIDIA_PROJECT
const int cudaVersion = cuda_get_runtime_version();
snprintf(buf, max, "%s/%s (Macintosh; Intel Mac OS X) libuv/%s CUDA/%d.%d clang/%d.%d.%d", APP_NAME, APP_VERSION, uv_version_string(), cudaVersion / 1000, cudaVersion % 100, __clang_major__, __clang_minor__, __clang_patchlevel__);
# else
snprintf(buf, max, "%s/%s (Macintosh; Intel Mac OS X) libuv/%s clang/%d.%d.%d", APP_NAME, APP_VERSION, uv_version_string(), __clang_major__, __clang_minor__, __clang_patchlevel__);
# endif

return buf;
Expand Down
6 changes: 3 additions & 3 deletions src/net/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,11 +582,11 @@ void Client::onRead(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf)
LOG_ERR("[%s:%u] read error: \"%s\"", client->m_url.host(), client->m_url.port(), uv_strerror((int) nread));
}

return client->close();;
return client->close();
}

if ((size_t) nread > (sizeof(m_buf) - 8 - client->m_recvBufPos)) {
return client->close();;
return client->close();
}

client->m_recvBufPos += nread;
Expand Down Expand Up @@ -623,7 +623,7 @@ void Client::onResolved(uv_getaddrinfo_t *req, int status, struct addrinfo *res)
auto client = getClient(req->data);
if (status < 0) {
LOG_ERR("[%s:%u] DNS error: \"%s\"", client->m_url.host(), client->m_url.port(), uv_strerror(status));
return client->reconnect();;
return client->reconnect();
}

addrinfo *ptr = res;
Expand Down
12 changes: 6 additions & 6 deletions src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Copyright 2014 Lucas Jones <https://github.com/lucasjones>
* Copyright 2014-2016 Wolf9466 <https://github.com/OhGodAPet>
* Copyright 2016 Jay D Dee <[email protected]>
* Copyright 2016-2017 XMRig <[email protected]>
* Copyright 2016-2018 XMRig <[email protected]>
*
*
* This program is free software: you can redistribute it and/or modify
Expand All @@ -27,19 +27,19 @@
#define APP_ID "xmrig"
#define APP_NAME "XMRig"
#define APP_DESC "XMRig CPU miner"
#define APP_VERSION "2.4.3.2"
#define APP_VERSION "2.4.4.1"
#define APP_DOMAIN "xmrig.com"
#define APP_SITE "www.xmrig.com"
#define APP_COPYRIGHT "Copyright (C) 2016-2017 xmrig.com"
#define APP_COPYRIGHT "Copyright (C) 2016-2018 xmrig.com"
#define APP_KIND "cpu"

#define APP_VER_MAJOR 2
#define APP_VER_MINOR 4
#define APP_VER_BUILD 3
#define APP_VER_REV 2
#define APP_VER_BUILD 4
#define APP_VER_REV 1

#ifdef _MSC_VER
# if (_MSC_VER == 1910 || _MSC_VER == 1911)
# if (_MSC_VER >= 1910)
# define MSVC_VERSION 2017
# elif _MSC_VER == 1900
# define MSVC_VERSION 2015
Expand Down

0 comments on commit 496ddab

Please sign in to comment.