Set shared_host when RigForge will share a Linux machine with other workloads. The profile is
opt-in; an omitted key or false keeps the dedicated-miner behavior.
{
"shared_host": {
"cpu_quota_percent": 100,
"memory_max_mb": 4096
},
"threads": 4
}cpu_quota_percent is a percentage of one CPU as understood by systemd: 100 permits one CPU,
200 permits two, and so on. It is a ceiling, not a promise of foreground-workload capacity or a
priority guarantee across unrelated cgroup hierarchies. It accepts integers from 1 through 10000.
memory_max_mb is the miner cgroup's resident-memory ceiling, including RandomX dataset
initialization, scratchpads, and helper processes. It accepts 3072 through 1048576 MiB. Set
threads when a lower initialization and mining thread ceiling is needed; without it the profile
uses one initialization thread.
The profile requires Linux systemd with unified cgroup v2 CPU and memory controllers, zero swap in
the miner cgroup, and enough statically visible memory to leave at least 1024 MiB outside the
configured ceiling and existing HugeTLB reservations. RigForge verifies the controls after systemd
activates them and refuses miner activation when the effective values cannot be read back. While a
loaded unit is out of profile, every start or restart is refused until apply runs again — including
the watchdog's thermal-hold lift and its wedge restart — while the watchdog's thermal stop stays
effective, so a hot miner is stopped regardless. status
and doctor report the selected profile, requested limits, effective limits, and unsupported,
not-enforced or stopped states. Because it never prompts for a password, status prints
Resource profile: unknown with the reason when its caller cannot read config.json, rather than
omitting the profile block.
Shared-host operation uses ordinary pages. It does not create or expand persistent HugePages,
change the CPU governor, apply MSR or cache tuning, enable NUMA, or rewrite pre-existing host
settings. XMRig runs with priority: 1, yield: true, no HugePages or memory pool, no MSR/cache
controls, and one dataset. The miner and RigForge's compile, prefetch, and periodic autotune helpers
run in the owned rigforge.slice budget. Full tune and bench are refused; tune --now and
periodic autotune only perform the limited prefetch work supported by the profile.
A rebuild during setup or upgrade sizes compiler parallelism from memory_max_mb (one job per
2 GiB, at least one) instead of host RAM, and stops a running miner first so the compiler has the
whole ceiling. Setup restarts the miner after the rebuild; upgrade restarts it when it was running
before. If setup or upgrade fails after the build has stopped the miner, the miner stays stopped;
fix the cause and run sudo ./rigforge.sh start.
The existing miner_user choice remains in force (root when omitted). The unit drops capabilities,
uses Nice=19 with CPU weight 10, and disables automatic restart so a failed budget check or memory
exhaustion leaves the miner stopped with a reason. Because the unit keeps no capabilities, RigForge
gives the generated XMRig config and xmrig.log to the miner account every time it re-owns the
worker directory. Without miner_user they are owned by root with the operator's group, and the
config is mode 0640 so non-root doctor and support-bundle can still read it. This bounds trusted mining workloads; it is not a
security boundary against compromised root code.
Switching an already installed dedicated unit requires stopping the miner and adding
"existing_host_tuning": "preserve" inside shared_host. This is an acknowledgement that RigForge
will preserve inherited host tuning; it does not inspect ownership, undo it, or reclaim it. If the
owned profile is later disabled, apply removes the shared budget and restores RigForge's dedicated
configuration. The next apply, upgrade, setup or uninstall
stops and removes the owned rigforge.slice once no process runs in it; while the miner or a helper
is still inside, removal waits for a later run of one of those commands. Shared selection or the retained history marker makes uninstall preserve global
tuning, even after disabling the profile, because ownership of inherited settings cannot be proven.
Apply the profile with sudo ./rigforge.sh apply after editing config.json. Repeated setup, apply,
upgrade, and reboot preserve the selected profile.
The opt-in shared-host phase of tests/e2e-pithead.sh (not part of all)
switches a provisioned rig to the profile, checks the effective slice limits, the miner's cgroup,
the generated XMRig settings, status, and an accepted share, then restores the dedicated
configuration. It compares HugePages, governors, the MSR module, the kernel command line and the
fstab, limits, modules and GRUB files before, during and after. Measured coexistence with a
foreground workload is the separate bench coexistence scenario owned by #579; the CPU quota and
memory ceiling alone do not establish that workload's service-level budget.
The XMRig controls follow the XMRig CPU configuration. The resource controls follow systemd resource control; HugeTLB accounting follows the kernel HugeTLB documentation.