From: "fuzzyrichie-gusto (Richard Desmarais) via ruby-core" Date: 2026-11-22T13:43:35+00:00 Subject: [ruby-core:127672] [Ruby Feature#22625] iseq memory improvements Issue #22625 has been reported by fuzzyrichie-gusto (Richard Desmarais). ---------------------------------------- Feature #22625: iseq memory improvements https://bugs.ruby-lang.org/issues/22625 * Author: fuzzyrichie-gusto (Richard Desmarais) * Status: Open ---------------------------------------- I am trying to reduce the memory footprint of our large application in multiple ways, and I was looking at what I could contribute to the Ruby codebase to do so. There's obviously some tradeoffs in memory vs time complexity, so I am being cautious on what I propose. Big memory wins with low CPU overhead should be proposed and worked on, but small memory wins with elevated CPU usage are probably not going to be interesting for most user. Here's a list of PRs related to this effort (outside of the two other iseq features proposed): https://github.com/ruby/ruby/pull/20073 - use variable-length instruction info blocks instead of a series of 8-byte entries (10% win, slower TracePoint queries) https://github.com/ruby/ruby/pull/20074 - shrink the rb_iseq_constant_body and move the rarely-used bytes into a side object - there's a catch: methods or blocks with more than 65,534 positional parameters fail. Seems like that might be OK as a tradeoff, but to be discussed. https://github.com/ruby/ruby/pull/20075 - cuts iseq malloc calls from 8 to 2, saving allocation count significantly - tradeoffs: compilation is slightly slower (3-5%), binary loading is about 5% slower, but freeing the iseq (using https://github.com/ruby/ruby/pull/20059) is 27% faster. So overall a net win if combined with the other PR. https://github.com/ruby/ruby/pull/20076 - opt_getconstant_path will malloc a single table across the VM instead of per-path mallocs - much less alloc count, but about 25MB off a 1.2GB app https://github.com/ruby/ruby/pull/20077 - outer_variables is stored as an array instead of a ID table. It needs to be sorted for Ractor error message support - only saves about 24MB off a 1.2GB app https://github.com/ruby/ruby/pull/20078 - Process.warmup will mark call-cache tables as GC-freeable - skipped when more than one Ractor is running - 24% memory reduction in certain applications, depending on what is built but not used -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/