ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: lourens@bearmetal.eu
To: ruby-core@ruby-lang.org
Subject: [ruby-core:95291] [Ruby master Feature#16245] Add interfaces to count and measure size all IMEMO objects
Date: Wed, 09 Oct 2019 11:00:42 +0000 (UTC)	[thread overview]
Message-ID: <redmine.journal-81971.20191009110042.7523a54dc7879ef7@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-16245.20191007220247@ruby-lang.org

Issue #16245 has been updated by methodmissing (Lourens Naudé).


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 strongly 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=>143, 
>    :global_constant_state=>1369, 
>    :class_serial=>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 way to grab a single metric this interface fits nicely. It does not expand the 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 family 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 #=> 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: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

  parent reply	other threads:[~2019-10-09 11:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <redmine.issue-16245.20191007220247@ruby-lang.org>
2019-10-07 22:02 ` [ruby-core:95267] [Ruby master Feature#16245] Add interfaces to count and measure size all IMEMO objects sam.saffron
2019-10-07 22:07 ` [ruby-core:95268] " sam.saffron
2019-10-07 22:52 ` [ruby-core:95272] " lourens
2019-10-08 17:55 ` [ruby-core:95281] " shevegen
2019-10-08 19:28 ` [ruby-core:95282] " eregontp
2019-10-09 10:49 ` [ruby-core:95289] " sam.saffron
2019-10-09 11:00 ` lourens [this message]
2019-10-16  5:52 ` [ruby-core:95353] " ko1
2019-10-17 21:16 ` [ruby-core:95404] " sam.saffron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=redmine.journal-81971.20191009110042.7523a54dc7879ef7@ruby-lang.org \
    --to=ruby-core@ruby-lang.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).