Runtime system options

The Haskell runtime system is a software layer that provides a set of services that enable Haskell programs to execute. At a high level, the Haskell runtime system provides the following services:

  1. Memory management: the Haskell runtime system manages the allocation and deallocation of memory used by the program. This includes allocating memory for data structures, managing the stack and heap, and freeing memory that is no longer in use.

  2. Garbage collection: the Haskell runtime system automatically collects and frees memory that is no longer being used by the program. This ensures that memory is used efficiently and helps to prevent memory leaks.

  3. Concurrency and parallelism: the Haskell runtime system provides support for concurrency and parallelism through features like lightweight threads, software transactional memory, and parallel arrays. This enables Haskell programs to take advantage of modern multicore processors and to execute computations in parallel.

  4. Exception handling: the Haskell runtime system provides a mechanism for handling exceptions that occur during program execution. This includes both synchronous exceptions, which occur as a result of a program error, and asynchronous exceptions, which occur as a result of external events such as signals.

IOG-released binaries are built with the following RTS options (-with-rtsopts): -T -I0 -A16m -N2 --disable-delayed-os-memory-return . This means that the node uses these options at runtime by default. You can check it thus:

Customized RTS options

Users have the option to select different configurations by adjusting the -with-rtsopts in the node's Cabal file and then building the node with the updated settings. For instance:

Users can extend and override options in -with-rtsopts by running cardano-node with command-line RTS options. To discover the available options, use the following command:

For example, this will extend the default options with -qg and -qb::

Where +RTS ... signals to the runtime system about passing runtime system options. The above example uses:

  • -T: produces runtime-system statistics, such as the amount of time spent executing the program and in the garbage collector, the amount of memory allocated, the maximum size of the heap, and so on. The three variants provide different levels of detail: -T collects the data but produces no output. Access the statistics using GHC.Stats.

  • -N2: specifies the number of threads to use for parallel execution. The -N2 flag indicates that the Haskell runtime system should use two parallel threads.

  • -A16m: sets the maximum heap size for the generational garbage collector to 16 megabytes.

  • -I0: specifies the amount of idle time that must pass before an idle GC is performed. Setting -I0 disables the idle GC.

  • --disable-delayed-os-memory-return: this option is used for accurate resident memory usage of the program, as shown in memory usage reporting tools (eg, the RSS column in top and htop). It makes it easier to verify the real memory usage.

  • qg: disables parallel GC, uses sequential GC.

  • qb: disables GC load balancing.

Last updated

Was this helpful?