Run Time System
The Acton Run Time System is what sets up the environment in which an Acton program runs. It performs bootstrapping of the root actor. The worker threads that carry out actual execution of actor continuations are part of the RTS. It is the RTS that handles scheduling of actors and the timer queue. All I/O is handled between modules in the standard library in conjunction with the RTS.
Arguments
It is possible to configure the RTS through a number of arguments. All arguments to the RTS start with --rts-. Use --rts-help to see a list of all arguments:
$ acton examples/helloworld.act
Building file examples/helloworld.act
Compiling helloworld.act for release
Finished compilation in 0.012 s
Final compilation step
Finished final compilation step in 0.198 s
$ examples/helloworld --rts-help
The Acton RTS reads and consumes the following options and arguments. All
other parameters are passed verbatim to the Acton application. Option
arguments can be passed either with --rts-option=ARG or --rts-option ARG
--rts-bt-dbg Interactively debug on SIGILL / SIGSEGV
--rts-debug RTS debug, requires program to be compiled with --debug
--rts-ddb-host=HOST DDB hostname
--rts-ddb-port=PORT DDB port [32000]
--rts-ddb-replication=FACTOR DDB replication factor [3]
--rts-node-id=ID RTS node ID
--rts-rack-id=RACK RTS rack ID
--rts-dc-id=DATACENTER RTS datacenter ID
--rts-host=RTSHOST RTS hostname
--rts-help Show this help
--rts-mon-log-path=PATH Path to RTS mon stats log
--rts-mon-log-period=PERIOD Periodicity of writing RTS mon stats log entry
--rts-mon-on-exit Print RTS mon stats to stdout on exit
--rts-mon-socket-path=PATH Path to unix socket to expose RTS mon stats
--rts-no-bt Disable automatic backtrace
--rts-perf Enable process hardware performance counters
--rts-log-path=PATH Path to RTS log
--rts-log-stderr Log to stderr in addition to log file
--rts-verbose Enable verbose RTS output
--rts-wthreads=COUNT Number of worker threads [#CPU cores]
$
Worker threads
Per default, the RTS starts as many worker threads as there are CPU threads available, although at least 4 and at most 255. This is optimized for server style workloads where it is presumed that the Acton program is the sole program consuming considerable resources. The limit of 255 is set when the program is built, with the max_wthreads build option.
It is possible to specify the number of worker threads with --rts-wthreads=COUNT, up to the same limit.
Actor method continuations run to completion, which is why it is wise not to set this value too low. Per default a minimum of 4 threads are started even when there are fewer CPU threads available, which means the operating system will switch between the threads inducing context switching overhead.
Performance counters
Use --rts-perf to enable cumulative process instructions and CPU cycles,
read through env.rts.perf_stats(). The RTS sets up counters before creating
collector and worker threads. acton test perf and acton test scale pass
this option automatically. Child processes need their own option to enable
counters.
env.rts.perf_info() reports whether counters are available. Hardware
measurements are None when unsupported or denied by the operating system.
Process CPU time and memory measurements do not require this option.
Open files
At startup, the RTS raises its soft limit on open files to the hard limit. On macOS it raises it to at most kern.maxfilesperproc. Systems set a low soft limit, 256 on macOS and 1024 on most Linux systems, for programs that use select(), which handles only file descriptors below 1024. Acton programs do not need it.
To run a program with a lower limit, lower the hard limit, for example with ulimit -Hn 4096. Child processes that the program starts inherit the raised limit.
env.rts.fd_stats() reads how many file descriptors the program has open and how many it may have open. A test can use it to check that some code does not leak descriptors, or to skip a case that needs more descriptors than the limit allows. On macOS, the limit is the soft limit capped at kern.maxfilesperproc, which is the limit the kernel enforces. On Windows, the count is the number of handles of the process, of every kind, and the limit is None.
Interactive debugging on crashes
If an Acton program crashes, --rts-bt-dbg is a convenient option for launching an interactive debugger. It is triggered on SIGILL / SIGSEGV and launches an interactive GDB session that allows for debugging the running program.
Acton programs do not normally crash with SIGILL / SIGSEGV but it possible either due to bugs in the compiler / RTS / builtins or more likely, for third party libraries that use C FFI, like for TLS, SSH, zlib or similar where a bug in the library triggers a crash on C level.