Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
Process.warmup
static VALUE
proc_warmup(VALUE _)
{
// Load the error decoration gems now so that their detailed_message
// decorators land in shared memory before a pre-forking server forks,
// instead of being loaded lazily on the first error at runtime.
rb_eager_load_detailed_message_extension();
RB_VM_LOCKING() {
rb_gc_prepare_heap();
}
return Qtrue;
}
Notify the Ruby virtual machine that the boot sequence is finished, and that now is a good time to optimize the application. This is useful for long running applications.
This method is expected to be called at the end of the application boot. If the application is deployed using a pre-forking model, Process.warmup should be called in the original process before the first fork.
The actual optimizations performed are entirely implementation specific and may change in the future without notice.
On CRuby, Process.warmup:
-
Performs a major
GC. -
Compacts the heap.
-
Promotes all surviving objects to the old generation.
-
Precomputes the coderange of all strings.
-
Frees all empty heap pages and increments the allocatable pages counter by the number of pages freed.
-
Invoke
malloc_trimif available to free empty malloc pages. -
Eagerly loads the error_highlight, did_you_mean, and syntax_suggest gems, which are otherwise loaded lazily on the first error display.
Ruby version changes
-
3.3
-
New
Process.warmupmethod that notify the Ruby virtual machine that the boot sequence is finished, and that now is a good time to optimize the application. This is useful for long-running applications. The actual optimizations performed are entirely implementation-specific and may change in the future without notice. [Feature #18885]
-