Global VM Lock

AppSignal for RubyThis feature requires version 3.3.9 or higher.
RubyThis feature requires version 3.2 or higher.
gvltoolsThis feature requires version 0.2 or higher.

The Ruby VM (Virtual Machine) schedules Ruby threads for execution. At any given point, only one thread at a time can interact with the state of the Ruby VM.

The mechanism by which the Ruby interpreter ensures this is the Global VM Lock (GVL).

Switching between threads has an overhead of its own. The metrics on the Global VM Lock allow you to see the time a thread spends waiting for its turn to run and the number of threads awaiting execution at a given time. These insights can provide helpful insights for understanding performance issues in your application.

When AppSignal detects Global VM Lock metrics, it will create an Automated Dashboard, allowing you to monitor core metrics visually.


The gvltools library is only compatible with the official Ruby interpreter. JRuby is not supported.

For AppSignal to be able to obtain Global VM Lock metrics, you must add the gvltools library to your project:

bundle add gvltools

Once installed, the AppSignal integration will automatically collect Global VM Lock metrics every minute.

Automated dashboards

Automated dashboards will appear in the dashboard section of the AppSignal app.

Ruby GVL Magic Dashoard creation

The Global VM automated dashboard has the following graphs:

Global timergvl_global_timerhostname
Waiting threadsgvl_waiting_threadshostname

Tags give you a contextual breakdown of Global VM performance information. AppSignal reports the following tags for Global VM performance:

hostnameThe name of the host the metric was reported from

Graphs allow you to monitor your application's metrics visually. You can add markers to graphs and click on any data point to gain insights into your application's state at that time.

Ruby GVL automated dashboard

Global timer graph

The Global timer graph shows the time that threads spent waiting to be resumed during the last minute, that is, waiting for their code to be executed again.

You can use the Global timer graph to monitor your application's concurrency and spot threading bottlenecks.

Configuring gvl_global_timer

The global timer metric has an estimated 5% overhead in measurement. To prevent negative impacts on your application's performance, you may want to disable gvl_global_timer by default and enable it when needed for specific requests or thread-intensive jobs.

To disable this metric, you can set the enable_gvl_global_timer configuration option to false.

You can use gvltools library to toggle the value without having to re-start your application:

require "gvltools" GVLTools::GlobalTimer.enable # some code that uses threads ... GVLTools::GlobalTimer.disable

Waiting threads graph

The Waiting threads graph shows the number of threads waiting to be resumed at any given time. The graph does not include threads that are not ready to be resumed, such as threads that are sleeping or awaiting an I/O event.

You can use the Global timer graph to monitor your application's concurrency and spot threading bottlenecks.

Configuring gvl_waiting_threads

To disable this metric, you can set the enable_gvl_waiting_threads configuration option to false.