diff options
author | Eric Wong <e@80x24.org> | 2019-06-10 09:52:13 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-06-10 09:52:13 +0000 |
commit | f5795a6092d6b4842e97bc67c11637d792961cb5 (patch) | |
tree | 30eada9950c7fbb745003645f41205fb0169f253 /lib | |
parent | c44825f8b2f3d57f6aca29d75516db8712261954 (diff) | |
download | public-inbox-malloc_info.tar.gz |
If run with PERL_INLINE_DIRECTORY for Inline::C support along with INBOX_DEBUG=malloc_info, we can allow users to opt-in to compiling extra code to support the glibc malloc_info(3) function. We'll also add SIGCONT handler to dump the malloc_info(3) output to stderr on our daemons.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/PublicInbox/Spawn.pm | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/PublicInbox/Spawn.pm b/lib/PublicInbox/Spawn.pm index 66b916df..9210f111 100644 --- a/lib/PublicInbox/Spawn.pm +++ b/lib/PublicInbox/Spawn.pm @@ -149,6 +149,23 @@ int pi_fork_exec(int in, int out, int err, } VFORK_SPAWN +# TODO: we may support other mallocs through this parameter +if (($ENV{INBOX_DEBUG} // '') =~ /\bmalloc_info\b/) { + $vfork_spawn .= <<MALLOC_DEBUG; +#include <malloc.h> + +int inbox_malloc_info(int options) +{ + int rc = malloc_info(options, stderr); + + return rc == 0 ? TRUE : FALSE; +} +MALLOC_DEBUG + + # dump malloc info to stderr on SIGCONT + $SIG{CONT} = sub { inbox_malloc_info(0) }; +} + my $inline_dir = $ENV{PERL_INLINE_DIRECTORY}; $vfork_spawn = undef unless defined $inline_dir && -d $inline_dir && -w _; if (defined $vfork_spawn) { |