if i have a process that i wish to run in the background on all cores, it can make the system extremely sluggish, even running at nice +20. Running out of memory or io is not the issue. Is there any easy way of reducing the cpu priority below this, or do i have to resort to starting the background process with fewer workerthreads than the number of cores, or some other kind of cpu management internal to the process.


You may want to look at idprio(1) and/or cpuset(1).

For example:

idprio 31 commandhere

would limit commandhere to idle priority. And

cpuset -l 0-3 commandhere

would limit it to cpu cores 0-3 only. To combine them:

cpuset -l 0 idprio 31 commandhere

(order could be switched to idprio 31 cpuset -l 0-3 commandhere, I don't think it matters). Which command or combination of commands arguments (priority or cpu list) depends on your workload of course, YMMV, etc.

  • 1
    idprio turned out to be what I was looking for. needs' 'security.bsd.unprivileged_idprio=1' to be set to make it usable by a non root user – camelccc May 23 '19 at 13:34

First solution

Use the limit command. As explained in the manpage :

limit, ulimit, unlimit - set or get limitations on the system resources available to the current shell and its descendents

Here is a link to the manpage.

Second solution

Use a jail, it can be used to isolate a process from the rest of your system and can limit CPU and memory usage too.

As explained here :

FreeBSD provides several methods for an administrator to limit the amount of system resources an individual may use. Disk quotas limit the amount of disk space available to users. Quotas are discussed in Section 17.11, “Disk Quotas”.

Limits to other resources, such as CPU and memory, can be set using either a flat file or a command to configure a resource limits database. The traditional method defines login classes by editing /etc/login.conf. While this method is still supported, any changes require a multi-step process of editing this file, rebuilding the resource database, making necessary changes to /etc/master.passwd, and rebuilding the password database. This can become time consuming, depending upon the number of users to configure.

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.