diff options
| author | bitflash <admin@bitflash.network> | 2026-08-20 18:03:27 -0300 |
|---|---|---|
| committer | bitflash <admin@bitflash.network> | 2026-08-20 18:03:27 -0300 |
| commit | bfce24bc542927647ae4e5af68b71e3e56e1a291 (patch) | |
| tree | a5f7566a29fbb20d14a68144ec8a2ed0ec4e7a30 /src | |
| parent | 3a128281cd8fec1c698346191c240a771f80d72c (diff) | |
randomx: make the large-pages fallback hint OS-specific
The reservation instruction printed when a large-page allocation falls back was
Linux-only (sysctl vm.nr_hugepages). Route it through a small helper so a
Windows build points at the "Lock pages in memory" privilege instead.
Diffstat (limited to 'src')
| -rw-r--r-- | src/randomx_pow.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/randomx_pow.cpp b/src/randomx_pow.cpp index 5872090..4454fd1 100644 --- a/src/randomx_pow.cpp +++ b/src/randomx_pow.cpp | |||
| @@ -34,6 +34,17 @@ static bool g_fLargeCache = false; | |||
| 34 | static bool g_fLargeDataset = false; | 34 | static bool g_fLargeDataset = false; |
| 35 | static bool g_fLargeAny = false; | 35 | static bool g_fLargeAny = false; |
| 36 | 36 | ||
| 37 | // How to reserve the large-page pool, for the hint printed when a large-page | ||
| 38 | // allocation falls back to normal pages. The mechanism is OS-specific. | ||
| 39 | static const char* LargePagesHint() | ||
| 40 | { | ||
| 41 | #ifdef _WIN32 | ||
| 42 | return "enable the \"Lock pages in memory\" privilege and run elevated"; | ||
| 43 | #else | ||
| 44 | return "reserve them with: sysctl vm.nr_hugepages=1280"; | ||
| 45 | #endif | ||
| 46 | } | ||
| 47 | |||
| 37 | static randomx_flags WithLargePages(randomx_flags f) | 48 | static randomx_flags WithLargePages(randomx_flags f) |
| 38 | { | 49 | { |
| 39 | return (randomx_flags)(f | RANDOMX_FLAG_LARGE_PAGES); | 50 | return (randomx_flags)(f | RANDOMX_FLAG_LARGE_PAGES); |
| @@ -99,8 +110,8 @@ bool RandomXInit() | |||
| 99 | printf("RandomX: initialized (cache 256 MB, flags=%d, large pages: %s)\n", | 110 | printf("RandomX: initialized (cache 256 MB, flags=%d, large pages: %s)\n", |
| 100 | (int)g_flags, RandomXLargePagesStatus()); | 111 | (int)g_flags, RandomXLargePagesStatus()); |
| 101 | if (fRandomXLargePages && !g_fLargeCache) | 112 | if (fRandomXLargePages && !g_fLargeCache) |
| 102 | printf("RandomX: large pages unavailable for the cache; " | 113 | printf("RandomX: large pages unavailable for the cache; %s " |
| 103 | "reserve them with sysctl vm.nr_hugepages=1280 for about 10%% more hash rate\n"); | 114 | "for about 10%% more hash rate\n", LargePagesHint()); |
| 104 | return true; | 115 | return true; |
| 105 | } | 116 | } |
| 106 | 117 | ||
| @@ -155,8 +166,8 @@ bool RandomXInitDataset(int nThreads) | |||
| 155 | g_dataset = randomx_alloc_dataset(WithLargePages(RANDOMX_FLAG_DEFAULT)); | 166 | g_dataset = randomx_alloc_dataset(WithLargePages(RANDOMX_FLAG_DEFAULT)); |
| 156 | g_fLargeDataset = (g_dataset != NULL); | 167 | g_fLargeDataset = (g_dataset != NULL); |
| 157 | if (!g_dataset) | 168 | if (!g_dataset) |
| 158 | printf("RandomX: large pages unavailable for the 2 GB dataset; " | 169 | printf("RandomX: large pages unavailable for the 2 GB dataset; %s " |
| 159 | "reserve 1280 with sysctl vm.nr_hugepages for about 10%% more hash rate\n"); | 170 | "for about 10%% more hash rate\n", LargePagesHint()); |
| 160 | } | 171 | } |
| 161 | if (!g_dataset) | 172 | if (!g_dataset) |
| 162 | g_dataset = randomx_alloc_dataset(RANDOMX_FLAG_DEFAULT); | 173 | g_dataset = randomx_alloc_dataset(RANDOMX_FLAG_DEFAULT); |