Ulimits on raad2

From TAMUQ Research Computing User Documentation Wiki
Jump to navigation Jump to search


Process Resources and Ulimits

Programs in execution are called processes. A process requires various resources in order to do its work. Some examples of resources include memory a process is able to use, or the amount of CPU time it may consume, or the number of files it is able to open simultaneously, etc. Usually, processes are subject to limits for each type of available resource, and this typically helps keep any given process from consuming unreasonable amounts of the concerned resources, causing problems for other processes. The default per-process limits work well for most processes, and the user can therefore remain oblivious to the issue of resource limits. In some cases, however, the defaults are not sufficient and a program will crash because not enough of something it needs is being made available. In these circumstances, it is possible for the user to raise her default limits for certain resources with the ulimit command before re-launching her program, and this will solve the problem. The reason the default limits for some of these resources are not kept at maximal levels in the first place is that this produces negative side-effects with certain types of programs. Each resource may have both a soft as well as a hard limit that is configured by the system admins. A hard limit cannot be increased by a regular user once it is set by the system admin; a soft limit may however be increased by the user up to the value of the hard limit.

Default Ulimits

The soft and hard limits effective inside your batch job can be displayed with the following two commands:

Soft Limits

ulimit -S -a

The soft limits output from the above command would be something like this:

core file size          (blocks, -c) 1
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 1032383
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) 32870400
open files                      (-n) 8192
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 258099
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited


Hard Limits

ulimit -H -a

The hard limits output from the above command would be something like this:

core file size          (blocks, -c) unlimited
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 1032383
max locked memory       (kbytes, -l) 123731968
max memory size         (kbytes, -m) 32870400
open files                      (-n) 16384
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 123731968
cpu time               (seconds, -t) unlimited
max user processes              (-u) 1032383
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

On the other hand, the “current” resource limits actually in effect may be displayed with:

ulimit -a

The current limits output from the above command would be something like this:

core file size          (blocks, -c) 1
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 1032383
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) 32870400
open files                      (-n) 8192
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 258099
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited


As you can see, initially, these values will be equivalent to the soft limit values until and unless they are modified by the user.

Change Ulimits

The user may, for instance, raise their current limits for “max locked memory” and “stack size” with the following two commands:

ulimit -l 67108864
ulimit -s 67108864

After these commands, “ulimit -a” will now show the following:

core file size          (blocks, -c) 1
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 1032383
max locked memory       (kbytes, -l) 67108864
max memory size         (kbytes, -m) 32870400
open files                      (-n) 8192
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 67108864
cpu time               (seconds, -t) unlimited
max user processes              (-u) 258099
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

Note that as a regular user, one would be able to raise neither the “max locked memory” nor the “stack size” limits beyond the hard limit values reported by the “ulimit -H -a” command earlier (which was 123731968 for both these resources in the example above).