diff options
author | Eric Wong <e@80x24.org> | 2019-10-29 07:13:59 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-10-31 00:36:48 +0000 |
commit | f6c7dbf5b8d4671c052b79f113fb92810ba958c8 (patch) | |
tree | e70d87309a3ff024837881a2993deeac2cec2b1b /README | |
parent | 29975ae0261f26d572422f7df2794cc339e6b426 (diff) | |
download | mwrap-f6c7dbf5b8d4671c052b79f113fb92810ba958c8.tar.gz |
I mainly use Perl5 (again :P), and sometimes tracking down where malloc calls happen is necessary. I don't know of any malloc wrapper interface which is aware of Perl source locations. Valgrind and similar tools can only figure out C source locations, which isn't very useful when hacking in Perl.
Diffstat (limited to 'README')
-rw-r--r-- | README | 86 |
1 files changed, 37 insertions, 49 deletions
@@ -1,95 +1,83 @@ -= mwrap - LD_PRELOAD malloc wrapper + line stats for Ruby +Devel::Mwrap - LD_PRELOAD malloc wrapper + line stats for Perl -mwrap is designed to answer the question: +Devel::Mwrap is designed to answer the question: - Which lines of Ruby are hitting malloc the most? + Which lines of Perl are hitting malloc the most? -mwrap wraps all malloc-family calls to trace the Ruby source -location of such calls and bytes allocated at each callsite. -As of mwrap 2.0.0, it can also function as a leak detector -and show live allocations at every call site. Depending on -your application and workload, the overhead is roughly a 50% -increase memory and runtime. +Devel::Mwrap wraps all malloc-family calls to trace the Perl source +location of such calls and bytes allocated at each callsite. It +can also function as a leak detector and show live allocations +at every call site. Depending on your application and workload, +the overhead is roughly a 50%-100% increase memory and runtime. -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 is thread-safe and requires the concurrent lock-free hash table +from the Userspace RCU project: https://liburcu.org/ -It requires the concurrent lock-free hash table from the -Userspace RCU project: https://liburcu.org/ +It relies on dynamic linking to a malloc(3) implementation. If +you got Perl from your OS distribution, this typically does not +require rebuilding Perl. -It does not require recompiling or rebuilding Ruby, but only -supports Ruby trunk (2.6.0dev+) on a few platforms: +Tested on the perl package distributed with: -* GNU/Linux -* FreeBSD (tested 11.1) +* Debian GNU/Linux 9, 10 -It may work on NetBSD, OpenBSD and DragonFly BSD. +It may work on FreeBSD, NetBSD, OpenBSD and DragonFly BSD. == Install - # FreeBSD: pkg install liburcu + # FreeBSD: pkg install pkg-config liburcu - # Debian-based systems: apt-get liburcu-dev - - # Install mwrap via RubyGems.org - gem install mwrap + # Debian-based systems: apt-get install pkg-config liburcu-dev == Usage -mwrap works as an LD_PRELOAD and supplies a mwrap RubyGem executable to +Devel::Mwrap works as an LD_PRELOAD and supplies a mwrap-perl script 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 + MWRAP=dump_path:/path/to/log mwrap-perl PERL_COMMAND # And to display the locations with the most allocations: sort -k1,1rn </path/to/log | $PAGER -You may also `require "mwrap"' in your Ruby code and use -Mwrap.dump, Mwrap.reset, Mwrap.each, etc. +You may also `use Devel::Mwrap' in your Perl code and use +Devel::Mwrap->dump, Devel::Mwrap->reset, Devel::Mwrap->each, etc. -However, mwrap MUST be loaded via LD_PRELOAD to have any +However, Devel::Mwrap MUST be loaded via LD_PRELOAD to have any effect in tracking malloc use. However, it is safe to keep -"require 'mwrap'" in performance-critical deployments, +"use Devel::Mwrap" in performance-critical deployments, as overhead is only incurred when used as an LD_PRELOAD. -The output of the mwrap dump is a text file with 3 columns: +The output of the Devel::Mwrap->dump is a text file with 3 columns: total_bytes call_count location -Where location is a Ruby source location (if made under GVL) -or an address retrieved by backtrace_symbols(3). It is -recommended to use the sort(1) command on either of the -first two columns to find the hottest malloc locations. - -mwrap 2.0.0+ also supports a Rack application endpoint, -it is documented at: - - https://80x24.org/mwrap/MwrapRack.html +Where location is a Perl source location or an address retrieved +by backtrace_symbols(3). It is recommended to use the sort(1) +command on either of the first two columns to find the hottest +malloc locations. == Known problems * 32-bit machines are prone to overflow (WONTFIX) -== Mail archives and list: +== Mail archives and newsgroup: - https://80x24.org/mwrap-public/ - nntp://80x24.org/inbox.comp.lang.ruby.mwrap + https://80x24.org/mwrap-perl/ + nntp://80x24.org/inbox.comp.lang.perl.mwrap No subscription will ever be required to post, but HTML mail will be rejected: - mwrap-public@80x24.org + mwrap-perl@80x24.org == Hacking - git clone https://80x24.org/mwrap.git + git clone https://80x24.org/mwrap-perl.git -Send all patches and pull requests (use "git request-pull" to format) to -the mailing list. We do not use centralized or proprietary messaging -systems. +Send all patches and pull requests (use "git request-pull" to format) +via email to mwrap-perl@80x24.org. We do not and will not use +proprietary messaging systems. == License |