← Graph

Ruby undef_method performance

concept 2 connections

Benchmark shown in the talk: defining and undef-ing methods across N modules-included-in-objects is far from linear in N. Digging into Ruby's C source (vm_method.c / class.c) reveals undef_method actually *adds* a method entry marked VM_METHOD_TYPE_UNDEF and, per profiling, spends roughly half its time clearing the method cache. Ruby code implemented in Ruby (Rubinius) scales more gracefully, so the cost is specific to MRI's implementation.

category
architecture
about
Ruby undef_method performance concept
Benchmarks and source-dives undef_method, showing super-linear cost and method-cache clearing overhead.
concept Ruby undef_method performance
related_to
Ruby tool
Implementation detail of MRI Ruby's method table and method cache.

Provenance

Read by
7 extractions