Skip to content
Snippets Groups Projects
Commit e9429667 authored by Tony Butler's avatar Tony Butler
Browse files

configEditor: add version tagging, line filtering per-platform

parent 2f096292
No related branches found
No related tags found
No related merge requests found
R"===( R"===(// generated by XMRSTAK_VERSION
/* /*
* GPU configuration. You should play around with intensity and worksize as the fastest settings will vary. * GPU configuration. You should play around with intensity and worksize as the fastest settings will vary.
* index - GPU index number usually starts from 0 * index - GPU index number usually starts from 0
...@@ -37,5 +38,4 @@ GPUCONFIG ...@@ -37,5 +38,4 @@ GPUCONFIG
* Platform index. This will be 0 unless you have different OpenCL platform - eg. AMD and Intel. * Platform index. This will be 0 unless you have different OpenCL platform - eg. AMD and Intel.
*/ */
"platform_index" : PLATFORMINDEX, "platform_index" : PLATFORMINDEX,
)===" )==="
R"===( R"===(// generated by XMRSTAK_VERSION
/* /*
* Thread configuration for each thread. Make sure it matches the number above. * Thread configuration for each thread. Make sure it matches the number above.
* low_power_mode - This can either be a boolean (true or false), or a number between 1 to 5. When set to true, * low_power_mode - This can either be a boolean (true or false), or a number between 1 to 5. When set to true,
...@@ -38,5 +39,4 @@ R"===( ...@@ -38,5 +39,4 @@ R"===(
[ [
CPUCONFIG CPUCONFIG
], ],
)===" )==="
R"===( R"===(// generated by XMRSTAK_VERSION
/* /*
* GPU configuration. You should play around with threads and blocks as the fastest settings will vary. * GPU configuration. You should play around with threads and blocks as the fastest settings will vary.
* index - GPU index number usually starts from 0. * index - GPU index number usually starts from 0.
...@@ -35,5 +36,4 @@ R"===( ...@@ -35,5 +36,4 @@ R"===(
[ [
GPUCONFIG GPUCONFIG
], ],
)===" )==="
R"===( R"===(// generated by XMRSTAK_VERSION
/* /*
* Network timeouts. * Network timeouts.
* Because of the way this client is written it doesn't need to constantly talk (keep-alive) to the server to make * Because of the way this client is written it doesn't need to constantly talk (keep-alive) to the server to make
...@@ -58,43 +59,53 @@ R"===( ...@@ -58,43 +59,53 @@ R"===(
* Large pages need a properly set up OS. It can be difficult if you are not used to systems administration, * Large pages need a properly set up OS. It can be difficult if you are not used to systems administration,
* but the performance results are worth the trouble - you will get around 20% boost. Slow memory mode is * but the performance results are worth the trouble - you will get around 20% boost. Slow memory mode is
* meant as a backup, you won't get stellar results there. If you are running into trouble, especially * meant as a backup, you won't get stellar results there. If you are running into trouble, especially
* on Windows, please read the common issues in the README. * on Windows, please read the common issues in the README and FAQ.
* *
* By default we will try to allocate large pages. This means you need to "Run As Administrator" on Windows. * By default we will try to allocate large pages. This means you need to "Run As Administrator" on Windows.---WINDOWS
* You need to edit your system's group policies to enable locking large pages. Here are the steps from MSDN * You need to edit your system's group policies to enable locking large pages. Here are the steps from MSDN---WINDOWS
* *---WINDOWS
* 1. On the Start menu, click Run. In the Open box, type gpedit.msc. * 1. On the Start menu, click Run. In the Open box, type gpedit.msc.---WINDOWS
* 2. On the Local Group Policy Editor console, expand Computer Configuration, and then expand Windows Settings. * 2. On the Local Group Policy Editor console, expand Computer Configuration, and then expand Windows Settings.---WINDOWS
* 3. Expand Security Settings, and then expand Local Policies. * 3. Expand Security Settings, and then expand Local Policies.---WINDOWS
* 4. Select the User Rights Assignment folder. * 4. Select the User Rights Assignment folder.---WINDOWS
* 5. The policies will be displayed in the details pane. * 5. The policies will be displayed in the details pane.---WINDOWS
* 6. In the pane, double-click Lock pages in memory. * 6. In the pane, double-click Lock pages in memory.---WINDOWS
* 7. In the Local Security Setting – Lock pages in memory dialog box, click Add User or Group. * 7. In the Local Security Setting – Lock pages in memory dialog box, click Add User or Group.---WINDOWS
* 8. In the Select Users, Service Accounts, or Groups dialog box, add an account that you will run the miner on * 8. In the Select Users, Service Accounts, or Groups dialog box, add an account that you will run the miner on---WINDOWS
* 9. Reboot for change to take effect. * 9. Reboot for change to take effect.---WINDOWS
* *---WINDOWS
* Windows also tends to fragment memory a lot. If you are running on a system with 4-8GB of RAM you might need * Windows also tends to fragment memory a lot. If you are running on a system with 4-8GB of RAM you might need---WINDOWS
* to switch off all the auto-start applications and reboot to have a large enough chunk of contiguous memory. * to switch off all the auto-start applications and reboot to have a large enough chunk of contiguous memory.---WINDOWS
* * On Linux you will need to configure large page support and increase your memlock limit (ulimit -l).---LINUX
* On Linux you will need to configure large page support "sudo sysctl -w vm.nr_hugepages=128" and increase your *---LINUX
* ulimit -l. To do do this you need to add following lines to /etc/security/limits.conf - "* soft memlock 262144" * To set large page support, add the following to "/etc/sysctl.d/60-hugepages.conf":---LINUX
* and "* hard memlock 262144". You can also do it Windows-style and simply run-as-root, but this is NOT * vm.nr_hugepages=128---LINUX
* recommended for security reasons. * You WILL need to run "sudo sysctl --system" for these settings to take effect on your system (or reboot).---LINUX
* * In some cases (many threads, very large CPU, etc) you may need more than 128---LINUX
* Memory locking means that the kernel can't swap out the page to disk - something that is unlikely to happen on a * (try 256 if there are still complaints from thread inits)---LINUX
* command line system that isn't starved of memory. I haven't observed any difference on a CLI Linux system between *---LINUX
* locked and unlocked memory. If that is your setup see option "no_mlck". * To increase the memlock (ulimit -l), add following lines to /etc/security/limits.d/60-memlock.conf:---LINUX
* * - memlock 262144---LINUX
* root - memlock 262144---LINUX
* You WILL need to log out and log back in for these settings to take effect on your user (no need to reboot, just relogin in your session).---LINUX
*---LINUX
* Check with "/sbin/sysctl vm.nr_hugepages ; ulimit -l" to validate---LINUX
*---LINUX
* Memory locking means that the kernel can't swap out the page to disk - something that is unlikely to happen on a---LINUX
* command line system that isn't starved of memory. I haven't observed any difference on a CLI Linux system between---LINUX
* locked and unlocked memory. If that is your setup see option "no_mlck".---LINUX
*/ */
/* /*
* use_slow_memory defines our behaviour with regards to large pages. There are three possible options here: * use_slow_memory defines our behaviour with regards to large pages. There are three possible options here:
* always - Don't even try to use large pages. Always use slow memory. * always - Don't even try to use large pages. Always use slow memory.
* warn - We will try to use large pages, but fall back to slow memory if that fails. * warn - We will try to use large pages, but fall back to slow memory if that fails.
* no_mlck - This option is only relevant on Linux, where we can use large pages without locking memory. * no_mlck - This option is only relevant on Linux, where we can use large pages without locking memory.---LINUX
* It will never use slow memory, but it won't attempt to mlock * It will never use slow memory, but it won't attempt to mlock---LINUX
* never - If we fail to allocate large pages we will print an error and exit. * never - If we fail to allocate large pages we will print an error and exit.
*/ */
"use_slow_memory" : "warn", "use_slow_memory" : "warn",---WINDOWS
"use_slow_memory" : "no_mlck",---LINUX
/* /*
* TLS Settings * TLS Settings
...@@ -149,6 +160,4 @@ R"===( ...@@ -149,6 +160,4 @@ R"===(
* This setting will only be needed in 2020's. No need to worry about it now. * This setting will only be needed in 2020's. No need to worry about it now.
*/ */
"prefer_ipv4" : true, "prefer_ipv4" : true,
)===" )==="
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <streambuf> #include <streambuf>
#include <regex> #include <regex>
#include "../version.hpp"
namespace xmrstak namespace xmrstak
{ {
...@@ -42,6 +43,24 @@ struct configEditor ...@@ -42,6 +43,24 @@ struct configEditor
void write(const std::string filename) void write(const std::string filename)
{ {
// endmarks: for filtering full lines inside the template string
// Platform marks are done globally here
// "---WINDOWS" endmark keeps lines when compiled for Windows
// "---LINUX" endmark keeps lines when compiled for Linux (and anything not-windows)
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__WINDOWS__)
// windows:
// completely drop lines with endmark-linux
replace(".*---LINUX\n", "");
// strip off windows endmarks, keep the lines
replace("---WINDOWS\n", "\n");
#else
// not-windows:
// completely drop lines with endmark-windows
replace(".*---WINDOWS\n", "");
// strip off linux endmarks, keep the lines
replace("---LINUX\n", "\n");
#endif
replace("XMRSTAK_VERSION", get_version_str());
std::ofstream out(filename); std::ofstream out(filename);
out << m_fileContent; out << m_fileContent;
out.close(); out.close();
......
R"===( R"===(// generated by XMRSTAK_VERSION
/* /*
* pool_address - Pool address should be in the form "pool.supportxmr.com:3333". Only stratum pools are supported. * pool_address - Pool address should be in the form "pool.supportxmr.com:3333". Only stratum pools are supported.
* wallet_address - Your wallet, or pool login. * wallet_address - Your wallet, or pool login.
...@@ -50,6 +51,4 @@ POOLCONF], ...@@ -50,6 +51,4 @@ POOLCONF],
*/ */
"currency" : "CURRENCY", "currency" : "CURRENCY",
)===" )==="
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment