Skip to content

Commit

Permalink
Merge pull request #1839 from Spudz76/dev-conf-endtags
Browse files Browse the repository at this point in the history
configEditor: add version tagging, line filtering per-platform
  • Loading branch information
psychocrypt authored Sep 24, 2018
2 parents 2f09629 + e942966 commit d7d4fe7
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 41 deletions.
4 changes: 2 additions & 2 deletions xmrstak/backend/amd/config.tpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
R"===(
R"===(// generated by XMRSTAK_VERSION

/*
* GPU configuration. You should play around with intensity and worksize as the fastest settings will vary.
* index - GPU index number usually starts from 0
Expand Down Expand Up @@ -37,5 +38,4 @@ GPUCONFIG
* Platform index. This will be 0 unless you have different OpenCL platform - eg. AMD and Intel.
*/
"platform_index" : PLATFORMINDEX,

)==="
4 changes: 2 additions & 2 deletions xmrstak/backend/cpu/config.tpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
R"===(
R"===(// generated by XMRSTAK_VERSION

/*
* 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,
Expand Down Expand Up @@ -38,5 +39,4 @@ R"===(
[
CPUCONFIG
],

)==="
4 changes: 2 additions & 2 deletions xmrstak/backend/nvidia/config.tpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
R"===(
R"===(// generated by XMRSTAK_VERSION

/*
* GPU configuration. You should play around with threads and blocks as the fastest settings will vary.
* index - GPU index number usually starts from 0.
Expand Down Expand Up @@ -35,5 +36,4 @@ R"===(
[
GPUCONFIG
],

)==="
73 changes: 41 additions & 32 deletions xmrstak/config.tpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
R"===(
R"===(// generated by XMRSTAK_VERSION

/*
* Network timeouts.
* Because of the way this client is written it doesn't need to constantly talk (keep-alive) to the server to make
Expand Down Expand Up @@ -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,
* 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
* on Windows, please read the common issues in the README.
*
* By default we will try to allocate large pages. This means you need to "Run As Administrator" on Windows.
* You need to edit your system's group policies to enable locking large pages. Here are the steps from MSDN
*
* 1. On the Start menu, click Run. In the Open box, type gpedit.msc.
* 2. On the Local Group Policy Editor console, expand Computer Configuration, and then expand Windows Settings.
* 3. Expand Security Settings, and then expand Local Policies.
* 4. Select the User Rights Assignment folder.
* 5. The policies will be displayed in the details pane.
* 6. In the pane, double-click Lock pages in memory.
* 7. In the Local Security Setting – Lock pages in memory dialog box, click Add User or Group.
* 8. In the Select Users, Service Accounts, or Groups dialog box, add an account that you will run the miner on
* 9. Reboot for change to take effect.
*
* Windows also tends to fragment memory a lot. If you are running on a system with 4-8GB of RAM you might need
* to switch off all the auto-start applications and reboot to have a large enough chunk of contiguous memory.
*
* On Linux you will need to configure large page support "sudo sysctl -w vm.nr_hugepages=128" and increase your
* ulimit -l. To do do this you need to add following lines to /etc/security/limits.conf - "* soft memlock 262144"
* and "* hard memlock 262144". You can also do it Windows-style and simply run-as-root, but this is NOT
* recommended for security reasons.
*
* Memory locking means that the kernel can't swap out the page to disk - something that is unlikely to happen on a
* command line system that isn't starved of memory. I haven't observed any difference on a CLI Linux system between
* locked and unlocked memory. If that is your setup see option "no_mlck".
* 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.---WINDOWS
* 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.---WINDOWS
* 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.---WINDOWS
* 4. Select the User Rights Assignment folder.---WINDOWS
* 5. The policies will be displayed in the details pane.---WINDOWS
* 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.---WINDOWS
* 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.---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
* 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
*---LINUX
* To set large page support, add the following to "/etc/sysctl.d/60-hugepages.conf":---LINUX
* vm.nr_hugepages=128---LINUX
* 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
* (try 256 if there are still complaints from thread inits)---LINUX
*---LINUX
* 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:
* 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.
* no_mlck - This option is only relevant on Linux, where we can use large pages without locking memory.
* It will never use slow memory, but it won't attempt to mlock
* 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---LINUX
* 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
Expand Down Expand Up @@ -149,6 +160,4 @@ R"===(
* This setting will only be needed in 2020's. No need to worry about it now.
*/
"prefer_ipv4" : true,

)==="

19 changes: 19 additions & 0 deletions xmrstak/misc/configEditor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <streambuf>
#include <regex>

#include "../version.hpp"

namespace xmrstak
{
Expand Down Expand Up @@ -42,6 +43,24 @@ struct configEditor

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);
out << m_fileContent;
out.close();
Expand Down
5 changes: 2 additions & 3 deletions xmrstak/pools.tpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
R"===(
R"===(// generated by XMRSTAK_VERSION

/*
* 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.
Expand Down Expand Up @@ -50,6 +51,4 @@ POOLCONF],
*/

"currency" : "CURRENCY",

)==="

0 comments on commit d7d4fe7

Please sign in to comment.