From: shevegen@... Date: 2019-10-08T17:55:42+00:00 Subject: [ruby-core:95281] [Ruby master Feature#16245] Add interfaces to count and measure size all IMEMO objects Issue #16245 has been updated by shevegen (Robert A. Heiler). Personally I love introspection so I am all in favour of giving ruby people lots of tools to play with internal. I also liked oldschool evi.rb. :) I guess this is for koichi to comment e. g. how stable he considers the gem/code; and possibly also whether the API is wanted in the first place. And perhaps also whether the name iseq is already an official name or not, ruby-internal wise (I really don't know, just pointing that out). As for the name **NonMaterializedInstructionSequences** - I think that name is too long and complicated. Ideally accessing should be simple, whenever possible, in my opinion. I am not even sure what a "non-materialized instruction sequence" is - is that ruby's version of a monoid-endofunctor monad? IMO, simpler names would be better. Although I guess if the functionality is what matters, then I guess we may agree that the functionality can be useful. methodmissing wrote: > I understand the API proposal, but also I believe the intention was for these > objects to be internal and not necessarily to be exposed through API. Yeah, I think I have read similar discussions in the past, also comments made by matz, koichi and shyouhei, in a different context. Which I guess makes sense too - less exposure may mean less problems. I am also neutral about the proposal really, don't mind either way - guess it may be for sam to reason in favour of it. :-) Even then, though, I love introspection in general. Ruby is like a closed box initially, just like on xmas (and the xmas release), and you get the tools to poke inside and try to find out how it works! \o/ Perhaps if it may help the discussion (not that I contribute much to it), there could be a discussion for potential problems in this regard, e. g. pitfalls, problems etc... or it may remain a separate gem, and it may be evaluated how useful it may be to integrate it into ruby directly. That discussion has also happened with other code elements / gems in the past, e. g. martin duerst pointed this out a few times before. But as said, I am really neutral either way here. ---------------------------------------- Feature #16245: Add interfaces to count and measure size all IMEMO objects https://bugs.ruby-lang.org/issues/16245#change-81959 * 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 #=> Integer ObjectSpace.memsize_of_all_iseq (should not generate RubyVM::InstructionSequence wrappers for IMEMOs) Since the wrapper object RubyVM::InstructionSequence is lazily allocated, ObjectSpace.each_object does not find these IMEMOs unless they have been wrapped. 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 via 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: