RHASH-CPU

Technical

For the people who read changelogs and technical info, read on.

Memory and huge pages

RandomX touches its 2 GB dataset at random. With normal 4 KB pages that means constant TLB misses; with 2 MB pages it mostly doesn't. Rhash-CPU puts the dataset, the 256 MB cache and every per-thread scratchpad on huge pages, and falls back in steps when it can't: 1 GB pages, then 2 MB hugetlb, then transparent huge pages, then 4 KB. Running as root, it reserves the pages it needs on the fly.

8 GB machines: reserving both 1 GB and 2 MB pools locks up more than 5 GB and can push the dataset into swap, where RandomX drops to a few H/s. Rhash-CPU uses free 1 GB pages automatically, and setup-ubuntu.sh reserves only about 140 small pages when 1 GB pages are configured.

On Windows

Windows calls them large pages and needs the "Lock pages in memory" right, which the app grants with one admin prompt (then sign out and back in). After a PC has been up for a while its free memory is chopped into small pieces and Windows may not find 2 GB of whole 2 MB blocks. Rhash-CPU then:

  • gives each mining thread its own 2 MB block first, since that's the biggest gain per megabyte;
  • if running elevated, frees standby memory the way RAMMap does and tries again;
  • builds the dataset from as many large-page pieces as it can find, with the rest on normal pages, and reports the share honestly, for example "Large pages: 72% - RAM fragmented".

Windows has no 1 GB pages and no MSR access without a kernel driver, so the same PC is a little faster on Linux.

RandomX engine

  • JIT with hardware AES and AVX2 Argon2. Programs compile to native x86-64.
  • Pipelined hashing. hash_first / hash_next overlap building program N+1 with running program N.
  • MSR mod. As root, applies the standard prefetcher tweak for Intel and AMD Zen 1 to Zen 5 (presets intel, ryzen_17h, ryzen_19h, ryzen_19h_zen4, ryzen_1Ah_zen5), worth roughly 10 to 15% on bare metal, and restores the original registers on exit.
  • JCC erratum padding. On Skylake-family Intel chips (6th to 10th gen Core and many Xeons), the JIT pads fused compare-and-branch pairs so they never cross a 32-byte boundary, where Intel's microcode fix would evict them from the uop cache. Automatic; --rx-jcc on|off to override.
  • Smaller JIT code. --rx-rcp on moves IMUL_RCP constants into a table, saving 6 bytes per use. scripts/rx-tune.sh A/B tests this and the JCC padding on your own CPU.
  • All hands on seed changes. Every logical CPU helps rebuild the dataset, which is then checked against an independent light-mode hash. If they disagree, you get a loud warning about unstable RAM or overclocks instead of rejected shares you can't explain.

Thread placement

The default thread count is the number of 2 MB scratchpads that fit in L3. Threads fill physical cores before Hyper-Threads and are spread across L3 domains, so 8 threads on a two-CCX Ryzen land 4 and 4 rather than 8 and 0. Multi-socket machines get one dataset per NUMA node, built by threads pinned to that node, and each worker reads only its local copy.

Next up is counting L2 as well on chips where it isn't duplicated in L3. See Hybrid cores and L2 cache.

GhostRider

GhostRider chains 18 hashes chosen by the previous block hash: 15 sphlib 512-bit functions and 3 of six CryptoNight-v1 variants. Rhash-CPU's AES-NI CryptoNight is one parameterised implementation covering all six. Each thread hashes 8 nonces per batch and runs each CryptoNight stage on 1, 2, 4 or 8 interleaved lanes so memory latency on one lane hides behind the others. Lane counts are auto-tuned in about 2 seconds at startup; override per variant with --gr-ways D,DL,F,L,T,TL.

  • The dark-lite and turtle-lite variants keep only the half of the scratchpad they actually address.
  • The main loop is software-pipelined with a table-driven variant-1 tweak.
  • CPUs with VAES fill and fold the scratchpad with 256-bit AES.

One story worth telling: GCC at -O3 miscompiles the reference CryptoNight finalizers because of strict-aliasing assumptions, which silently produced wrong hashes until our oracle caught it. Those files are now built with -fno-strict-aliasing.

VerusHash 2.2

Per job, the 1,487-byte header is absorbed once and the 8,832-byte CLMUL key is generated once; after each hash only the entries it changed are restored. The nonce lives in the solution's tail. PBaaS merge-mining headers are canonicalised exactly as pools verify them, with the pre-header blake2b kept in sync with the nonce.

yespower and yescrypt

Based on Openwall's yespower-opt. Each thread's 2 to 16 MB region sits on 2 MB huge pages (upstream only does that above 12 MB). Eleven presets are built in and any other coin works with --yespower-n, --yespower-r, --yespower-pers and --yespower-version 5|10.

Correctness

A fast miner that sends bad shares is slow. Rhash-CPU is checked three ways:

  • Startup self-test. Official test vectors run through the exact code path used for mining (JIT, AES, lane counts). If anything doesn't match, the miner refuses to start.
  • Independent mock pools. The test suite has verifying pools that re-hash every submitted share with reference code that shares nothing with the miner: the unmodified RandomX library, Openwall's yespower-ref.c, verushash-node, and Raptoreum's cn_slow_hash. They rebuild every header themselves (coinbase, merkle branches, word-swapped prevhash) and check target, duplicates and the rx/2 commitment.
  • Negative tests. A wrong personalisation string is rejected every time (9 of 9), so the pools aren't just saying yes.

Pools and network

  • Three stratum dialects: CryptoNote (RandomX), Bitcoin-style (yespower, GhostRider) and Verus.
  • TLS 1.3, with optional certificate pinning: --tls-fingerprint refuses a mismatched certificate.
  • Failover with repeated -o; -u, -p and --tls apply to the pool they follow.
  • --nicehash reserves the top nonce byte for NiceHash and proxies.
  • Saved pools in pools.json (mode 0600), with automatic history of pools that connected.

Built-in diagnostics

The banner says whether you're on bare metal, a VM or a container, plus any cgroup CPU quota, free RAM and swap. While mining, and at the end of --bench, Rhash-CPU compares CPU time with wall-clock time and warns about throttling, hypervisor steal time, swapping, and huge pages that were reserved but couldn't be used, with the reason. On Windows the GUI reads CPU load, clocks, memory and DIMMs.

The dev fee

Dev fee is 0.5%, less than the others. If you submit 10,000 shares, you're giving 50 away. With other software at 1%, you'd give away 100. We're only half of that.

Building from source

Linux, C++17, CMake and OpenSSL. GCC 13 and Clang 18 build it without warnings.

sudo apt install -y build-essential cmake libssl-dev
tar xzf rhash-cpu-linux-current.tar.gz && cd rhash-cpu
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build -j$(nproc)
./build/rhash-cpu --version

Fedora: gcc-c++ cmake openssl-devel. Arch: base-devel cmake openssl. Rhash-CPU's own code is MIT; RandomX (BSD-3), nlohmann/json (MIT), yespower (BSD-style), sphlib (MIT) and VerusHash/haraka (MIT/Apache-2) keep their licences. No GPL code is included.