mwrap user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: mwrap-public@80x24.org
Cc: Sam Saffron <sam.saffron@gmail.com>
Subject: dropping Mwrap::HeapPageBody memalign tracking
Date: Fri, 6 Jan 2023 21:59:09 +0000	[thread overview]
Message-ID: <20230106215909.M940137@dcvr> (raw)

Ruby 3.1 switched to mmap for HPB in 2021, and I doubt it'll be
going back to *memalign on Linux or FreeBSD.  HPB stats don't
exist at all for 3.1+ right now.

Tracking mmap allocations safely would be significantly more
difficult and expensive since munmap can cross mmap-ed regions.

With *memalign + free, there's a simple 1:1 relationship,
but not with mmap + munmap.

munmap can work on any subset (or even superset if multiple mmap
calls return sequential pages) of addresses within any mmap-ed
region(s).  In other words, each 4k page would need a
separately-allocated tracking struct in a process-wide tree or
hash table.

I don't think Ruby currently does asymmetric mmap/munmap; but
extensions and any spawned processes may and it's the only safe
way to account for it.

So the tracking is definitely doable, but I'm not sure it's
worth the time and effort.  These are GC-internal allocations
and any instrumentation for the GC itself is probably better off
being added to ruby/gc.c



There's something similar on the Perl 5 side, too.  It allocates
small strings out of 4080-byte malloc-ed arenas and I was
confused with 4080-byte allocations until I cranked up C
backtraces via MWRAP=bt:$N.

I think a better long-term feature would be to be able to
interactively crank up C backtrace levels on a per-callsite
basis.  Right now, the C backtrace level is global, and
increasing that interactively gets expensive fast.

             reply	other threads:[~2023-01-06 21:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-06 21:59 Eric Wong [this message]
2023-01-07 21:51 ` [PATCH] drop heap page support for Ruby <= 3.0 Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://80x24.org/mwrap/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230106215909.M940137@dcvr \
    --to=e@80x24.org \
    --cc=mwrap-public@80x24.org \
    --cc=sam.saffron@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mwrap.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).