Method: Process.warmup

Defined in:
process.c

.warmuptrue

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_trim if available to free empty malloc pages.

Returns:

  • (true)


8856
8857
8858
8859
8860
8861
8862
8863
# File 'process.c', line 8856

static VALUE
proc_warmup(VALUE _)
{
    RB_VM_LOCK_ENTER();
    rb_gc_prepare_heap();
    RB_VM_LOCK_LEAVE();
    return Qtrue;
}