[ruby-core:95291] [Ruby master Feature#16245] Add interfaces to count and measure size all IMEMO objects
From:
lourens@...
Date:
2019-10-09 11:00:42 UTC
List:
ruby-core #95291
Issue #16245 has been updated by methodmissing (Lourens Naud=E9).
I like this API more, however `RubyVM` has been under discussion in https:/=
/bugs.ruby-lang.org/issues/15752 regarding implementation specific exposure=
of experimental API and / or insights. These 2 issues are in a way strongl=
y coupled.
sam.saffron (Sam Saffron) wrote:
> To be honest I think the best spot for this is `RubyVM.stat`
> =
> perhaps:
> =
> ```
> RubyVM.stat
> {
> :global_method_state=3D>143, =
> :global_constant_state=3D>1369, =
> :class_serial=3D>8768,
> :imemo_ment_count,
> :imemo_iseq_count,
> :imemo_env_count,
> :imemo_tmpbuf_count,
> :imemo_ast_count,
> :imemo_ment_size,
> :imemo_iseq_size,
> :imemo_env_size,
> :imemo_tmpbuf_size,
> :imemo_ast_size
> }
> ```
> =
> Since `RubyVM.stat(:class_serial)` is already supported as an efficient w=
ay to grab a single metric this interface fits nicely. It does not expand t=
he signature surface of Ruby and is something that would be very simple to =
add for 2.7. =
> =
> =
> Additionally for extra bonus points: =
> =
> =
> RubyVM.stat(:total_allocated_bytes): all the bytes Ruby xmalloc and famil=
y allocated since process start
> RubyVM.stat(:total_freed_bytes): all the bytes freed
> =
> =
> This comprehensive set of changes would make introspection of "why is my =
Ruby size XYZ?" really easy and provide some extremely powerful metrics for=
graphing.
> =
> Thoughts?
----------------------------------------
Feature #16245: Add interfaces to count and measure size all IMEMO objects
https://bugs.ruby-lang.org/issues/16245#change-81971
* Author: sam.saffron (Sam Saffron)
* Status: Open
* Priority: Normal
* Assignee: =
* Target version: =
----------------------------------------
Koichi introduced an experimental gem: https://github.com/ko1/iseq_collector
It allows:
ObjectSpace.each_iseq{|iseq| ...}
ObjectSpace.count_iseq #=3D> Integer
ObjectSpace.memsize_of_all_iseq (should not generate RubyVM::InstructionSeq=
uence wrappers for IMEMOs)
Since the wrapper object RubyVM::InstructionSequence is lazily allocated, =
ObjectSpace.each_object does not find these IMEMOs unless they have been wr=
apped. This design is good and conserves memory. =
`count_iseq` and `memsize_of_all_iseq` are very powerful metrics most large=
Ruby deployments can use to automatically detect method leaks introduced v=
ia meta programming. These issues are invisible now short of walking a heap=
dump. =
Can we add the new interface into 2.7?
-- =
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=3Dunsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>