From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-3.9 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id AFC6B1F4BD for ; Wed, 9 Oct 2019 11:00:51 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 5E22F120A76; Wed, 9 Oct 2019 20:00:42 +0900 (JST) Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by neon.ruby-lang.org (Postfix) with ESMTPS id 43008120A73 for ; Wed, 9 Oct 2019 20:00:37 +0900 (JST) Received: by filter0034p3iad2.sendgrid.net with SMTP id filter0034p3iad2-19440-5D9DBDDA-37 2019-10-09 11:00:42.237969542 +0000 UTC m=+489166.835427119 Received: from herokuapp.com (unknown [54.167.22.24]) by ismtpd0013p1iad2.sendgrid.net (SG) with ESMTP id J5uO5vZDQi6_HpQtvwBfXA for ; Wed, 09 Oct 2019 11:00:42.269 +0000 (UTC) Date: Wed, 09 Oct 2019 11:00:42 +0000 (UTC) From: lourens@bearmetal.eu Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 70878 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 16245 X-Redmine-Issue-Author: sam.saffron X-Redmine-Sender: methodmissing X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?Fr=2F4MkNsnJ5O85XS4movydqTd1a9M98=2FgJAFvUl026OE6MsYU2zHRoI1FqEshm?= =?us-ascii?Q?FTKrWN1XaQsRuCwzLFkkoa38wWI3RDBdhnkND07?= =?us-ascii?Q?jf5zZQEVgPZ6wrqMIDrTCB9+1n0yURx6Y=2FGmrgh?= =?us-ascii?Q?OU6iE6P+zopbODB39zwycSQxq9zSv+bFi=2FObVPZ?= =?us-ascii?Q?cyTWiMyrSGiVoX0AmSrj6KRwk7cRxl6YbdQ=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 95291 Subject: [ruby-core:95291] [Ruby master Feature#16245] Add interfaces to count and measure size all IMEMO objects X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" 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: