10

When I run cpuminer-multi as a normal user, the first message I get is "I go faster as root". It indeed does not appear anymore when run as root (with command sudo)

What is made possible by being root? Is it safe?

10

There are two operations at the operating system level that can be perform to improve performance in some cases but require the software to be run as superuser (root). This is mostly useful for a user who want to mine while using their computer intensively for other tasks (see comments by Gilles and hyc below).

Setting niceness

Niceness on Unix systems is a level of priority for a task relatively to others. It is enforced by the kernel. If priority is the same as other tasks, the access to the CPU is not optimal.

Niceness is set to 6 instead of the default 20 (the lower the niceness is, the higher the priority is)

Locking memory

If the system does not have enough RAM, part of it might be moved to the swap space when not used and then moved again to RAM when needed. This cause CPU time to be spoiled. The system call [mlock][3] allows to lock a variable in RAM. Variable persistentctx (of type cryptonight_ctx) contains the context of Cryptonight algorithm and is protected.

Is it safe ?

You must be careful when running a software as root on your computer. There is however no risk here is you've download the mining software from the official repository.

Note that these optimizations are not in lucasjones original software but have been added by wolf9466 (however it tried to change niceness regardless of user but was not advising to run as root).

  • 3
    These two features improve performance only if there are other things using CPU time on the machine (significant CPU time for niceness, occasional CPU time plus significant memory for locking in RAM), in which case it is probably not desirable that mining takes priority over whatever else the machine is doing. So if that's all that's gained by running as root, it's usually pointless if not undesirable. – Gilles Sep 5 '16 at 17:24
  • 1
    Note that mlock isn't needed if you've allocated some hugepages for mining. (Huge pages cannot be paged out, so there's no need to call mlock on them.) You get a bigger performance boost from using hugepages, and you don't need root access to use them. (But you needed to be root at some point to configure them.) – hyc Sep 5 '16 at 18:52
  • Thanks you both for these complements.These optimizations are indeed only useful in some limited cases. – Clement J. Sep 10 '16 at 13:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.