From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: poffice@blade.nagaokaut.ac.jp Delivered-To: poffice@blade.nagaokaut.ac.jp Received: from kankan.nagaokaut.ac.jp (kankan.nagaokaut.ac.jp [133.44.2.24]) by blade.nagaokaut.ac.jp (Postfix) with ESMTP id B5AD719C0045 for ; Tue, 24 Nov 2015 09:34:19 +0900 (JST) Received: from voscc.nagaokaut.ac.jp (voscc.nagaokaut.ac.jp [133.44.1.100]) by kankan.nagaokaut.ac.jp (Postfix) with ESMTP id 0B52AB5DBC1 for ; Tue, 24 Nov 2015 06:37:23 +0900 (JST) Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by voscc.nagaokaut.ac.jp (Postfix) with ESMTP id 2FC8918CC7E6 for ; Tue, 24 Nov 2015 06:37:23 +0900 (JST) Received: from [221.186.184.76] (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id 7A59812045C; Tue, 24 Nov 2015 06:37:20 +0900 (JST) X-Original-To: ruby-core@ruby-lang.org Delivered-To: ruby-core@ruby-lang.org Received: from o10.shared.sendgrid.net (o10.shared.sendgrid.net [173.193.132.135]) by neon.ruby-lang.org (Postfix) with ESMTPS id F2772120433 for ; Tue, 24 Nov 2015 06:37:13 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.me; h=from:to:references:subject:mime-version:content-type:content-transfer-encoding:list-id; s=smtpapi; bh=bS1584dxJ8ztW4dB1NPmpR6jKRk=; b=GLqYal8nn+ZRrDofIZ rU+f6NeNmXwK6BG7/bi6uAYn4isIFX2UYOa6IVRnFUmdPFbcxf5IBmQSzo6Ir4Ix 0+MouIT7Zm6uyV/bOtuP8MVu08rOXt1j8H7pKA98HU2bvuulHxT7nZzxsH/4VYnT pAJyuJI5W+bdTDkk4p7eSuh80= Received: by filter0544p1mdw1.sendgrid.net with SMTP id filter0544p1mdw1.7575.565387032F 2015-11-23 21:37:07.72475114 +0000 UTC Received: from herokuapp.com (ec2-54-167-90-158.compute-1.amazonaws.com [54.167.90.158]) by ismtpd0002p1iad1.sendgrid.net (SG) with ESMTP id MhYLnxktRm-ccqYEdq5w4w Mon, 23 Nov 2015 21:37:07.679 +0000 (UTC) Date: Mon, 23 Nov 2015 21:37:07 +0000 From: yosy101@gmail.com To: ruby-core@ruby-lang.org Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Redmine-MailingListIntegration-Message-Ids: 46318 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 11599 X-Redmine-Issue-Author: yosiat X-Redmine-Issue-Assignee: nobu X-Redmine-Sender: yosiat 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: ync6xU2WACa70kv/Ymy4QrNMhiuLXJG8OTL2vJD1yS7xm72xUTmCqnUANbBj+RNGmTMrepcMhex6JG q0yyDwNqYW9ABqxSuZWKC3VpxDuUM38/mj24GdnIDAPFh7Vuz+DRrxbYyF+NPWo7C+5xv2IQn7xFE7 kHhVihEhEyUaBbUPRwN2K48k/ONiUTnJ1Lxa X-ML-Name: ruby-core X-Mail-Count: 71645 Subject: [ruby-core:71645] [Ruby trunk - Feature #11599] Dump entries of hash in ObjectSpace 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: , Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" Issue #11599 has been updated by Yosi Attias. Aaron Patterson wrote: > We should probably get Aman's opinion on this since he wrote the initial heap dumping code. Personally, I would like to see this feature enabled with a flag. It seems like it will significantly increase the size of the dump file, and also the dumped data will not be backwards compatible. Maybe if we add a flag to the `dump` method it would be easier to take this patch? Thanks :) Just throwing out - If the dump size is something that matters and we want to decrease it - I am thinking about writing in some binary format (msgpack/protobuf, with protobuf you will get backward compatible). ---------------------------------------- Feature #11599: Dump entries of hash in ObjectSpace https://bugs.ruby-lang.org/issues/11599#change-55048 * Author: Yosi Attias * Status: Open * Priority: Normal * Assignee: Nobuyoshi Nakada ---------------------------------------- Hi, *This is my first c code contribution :)* I am helping developing heap-analyzer (github.com/tenderlove/heap-analyzer), and currently the dumps lacks of "type metadata" information, like: * Hash entries - the keys and value * Array items - the items of the array etc. In the included patch, I have changed the dump of hash to add entries of hash. For example, given the next hash: ~~~ruby hash = { int_key: 1, str_key: "This is my string", inner_hash: { b: 2 } } ~~~ The dump result (ObjectSpace.dump(hash)) will be: ~~~json { "address": "0x007fbc01110340", "type": "HASH", "class": "0x007fbc0109b400", "size": 3, "entries": [ { "is_key_address": false, "key": ":int_key", "is_value_address": false, "value": "1" }, { "is_key_address": false, "key": ":str_key", "is_value_address": true, "value": "0x007fbc01110390" }, { "is_key_address": false, "key": ":inner_hash", "is_value_address": true, "value": "0x007fbc01110368" } ], "references": [ "0x007fbc01110390", "0x007fbc01110368" ], "memsize": 232, "flags": { "wb_protected": true } } ~~~ As you can see, I have the "entries" array, where each entry contains: "is_key_address", "is_value_address" - if the key/value are special consts the inspected value will be printed in the "key"/"value" properties, other their address will be print. Hope you will accept the patch (and I can submit another one for arrays), Yosi. ---Files-------------------------------- objspace_dump_hash_entries.patch (4.8 KB) objspace_dump.patch (4.53 KB) -- https://bugs.ruby-lang.org/