# Tuning Ruby's Global Method Cache

DevFeed: [Tuning Ruby's Global Method Cache](<https://devfeed.tech/articles/tuning-ruby-s-global-method-cache-1274.md>)

Original publisher: [Read original article](<https://shopify.engineering/17489064-tuning-rubys-global-method-cache>)

Author: Scott Francis

Published: 2015-01-21T15:52:00Z

Content type: article

Language: en

Sources: [Shopify Engineering](<https://devfeed.tech/sources/shopify-engineering.md>), [Shopify Engineering - Shopify Engineering](<https://devfeed.tech/sources/shopify-engineering-shopify-engineering.md>)

Topics: [Ruby](<https://devfeed.tech/topics/ruby.md>), [Cache](<https://devfeed.tech/topics/cache.md>), [Linux](<https://devfeed.tech/topics/linux.md>), [debug](<https://devfeed.tech/topics/debug.md>), [Tooling](<https://devfeed.tech/topics/tooling.md>), [Shopify](<https://devfeed.tech/topics/shopify.md>)

Tags: [cache](<https://devfeed.tech/tags/cache.md>), [linux](<https://devfeed.tech/tags/linux.md>), [production](<https://devfeed.tech/tags/production.md>), [profiling](<https://devfeed.tech/tags/profiling.md>), [ruby](<https://devfeed.tech/tags/ruby.md>), [server](<https://devfeed.tech/tags/server.md>), [shopify](<https://devfeed.tech/tags/shopify.md>)

## AI overview

This article explains how Shopify engineers investigated time spent in Ruby MRI's st_lookup function while profiling a production application server. It describes using perf call graphs, Linux stack snapshots, DWARF debugging information, and SystemTap to trace callers and understand global method cache lookups and invalidation.

## Source excerpt

I was recently profiling a production Shopify application server using perf and noticed a fair amount of time being spent in a particular function, st_lookup, which is used by Ruby's MRI implementation for hash table lookups: Hash tables are used all over MRI, and not just for the Hash object; global variables, instance variables, classes, and the garbage collector all use MRI's internal hash table implementation, st_table. Unfortunately, what this profile did not show were the callers of st_lookup. Is this some application code that has gone wild? Is this an inefficiency in the VM?