Prevent the machine from going to sleep during a long computation, and allow it again afterwards.
This exists because a system sleep is invisible to every in-process measurement. While the machine is asleep wall clock advances and CPU time does not, so a step that spans a sleep appears many times slower while doing identical work: recorded pipeline timings have been inflated 5-14x this way, with CPU-seconds, memory and I/O counters all looking entirely normal.
Nothing in Giotto holds a sleep assertion unless you call keep_awake() or
gwith_awake(). Attaching the package changes no power settings.
Details
Uses caffeinate on macOS and systemd-inhibit on Linux; on other platforms,
or when neither is available, it reports that it cannot help and does nothing.
No sleep assertion can outlive the R session: on both platforms the helper is
bound to this process and exits with it. For the same reason, sessions running
side by side on one machine hold and release independently.
Idempotent within a session — calling it repeatedly with on = TRUE leaves a
single helper. A session only ever tracks and releases the helper it started
itself, so it cannot report another session's hold as its own.
Options
giotto.prevent_sleepwhen
FALSE,keep_awake(TRUE)andgwith_awake()become no-ops (defaultTRUE). This is a kill switch for shared machines, cluster nodes and CI, where holding a power assertion is unwanted; it does not cause anything to hold one on its own. It gates taking an assertion only —keep_awake(FALSE)still releases one that is already held, so setting the option partway through cannot strand it.
See also
gwith_awake() to scope it to a block of code
