From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-3.3 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.1 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 86DAF1F516; Mon, 2 Jul 2018 12:00:50 +0000 (UTC) Date: Mon, 2 Jul 2018 12:00:50 +0000 From: Eric Wong To: ruby-talk@ruby-lang.org, mwrap-public@80x24.org Subject: [ANN] mwrap - LD_PRELOAD malloc wrapper + line stats for Ruby Message-ID: <20180702120050.GA24029@dcvr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline List-Id: mwrap is designed to answer the question: Which lines of Ruby are hitting malloc the most? mwrap wraps all malloc, calloc, and realloc calls to trace the Ruby source location of such calls and bytes allocated at each callsite. This functionality may be expanded in the future. It does not track allocation lifetimes, or frees, however. It works best for allocations under GVL, but tries to track numeric caller addresses for allocations made without GVL so you can get an idea of how much memory usage certain extensions and native libraries use. It requires the concurrent lock-free hash table from the Userspace RCU project: https://liburcu.org/ It does not require recompiling or rebuilding Ruby, but only supports Ruby trunk (2.6.0dev+) on a few platforms: * GNU/Linux * FreeBSD (tested 11.1) It may work on NetBSD, OpenBSD and DragonFly BSD. == Install # FreeBSD: pkg install liburcu # Debian-based systems: apt-get liburcu-dev # Install mwrap via RubyGems.org gem install mwrap == Usage mwrap works as an LD_PRELOAD and supplies a mwrap RubyGem executable to improve ease-of-use. You can set dump_path: in the MWRAP environment variable to append the results to a log file: MWRAP=dump_path:/path/to/log mwrap RUBY_COMMAND # And to display the locations with the most allocations: sort -k1,1rn -- https://80x24.org/mwrap/README.html https://80x24.org/mwrap/Mwrap.html