Global VM Lock
The Ruby VM (Virtual Machine) schedules Ruby threads for execution. At any given point, only one thread at a time can be active and 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 metrics 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.
Installation
For AppSignal to be able to obtain Global VM Lock metrics, you must add the gvltools
library to your project:
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 AppSignal.
The Global VM Lock automated dashboard has the following graphs:
Graph | Metric |
---|---|
Global timer | gvl_global_timer |
Waiting threads | gvl_waiting_threads |
AppSignal reports the following tags for Global VM Lock metrics:
Name | Description |
---|---|
hostname | The name of the host that the metric was reported from |
process_id | The ID of the process that the metric was reported from |
process_name | The name of the process that the metric was reported from |
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.
Configuring global timer measurement
Measuring the global timer has an estimated performance overhead of 5%.
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 at start time, set the enable_gvl_global_timer
configuration option to false
.
Then, you can use the gvltools
library to enable and disable the global timer measurement without having to restart your application:
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.
To disable this metric, you can set the enable_gvl_waiting_threads
configuration option to false
.