unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Pip Cet <pipcet@gmail.com>
Cc: 46900@debbugs.gnu.org
Subject: bug#46900: 28.0.50; GC uses excessive amounts of stack
Date: Wed, 03 Mar 2021 18:28:23 +0200	[thread overview]
Message-ID: <83wnuojj6g.fsf@gnu.org> (raw)
In-Reply-To: <CAOqdjBc4DEUrNddC+umGnjN5CUyxi9QbB-MCk8MM3HW7FPaZ2g@mail.gmail.com> (message from Pip Cet on Wed, 3 Mar 2021 15:44:33 +0000)

> From: Pip Cet <pipcet@gmail.com>
> Date: Wed, 3 Mar 2021 15:44:33 +0000
> 
> Currently, GC is written to recurse when marking objects. That means
> for every level of recursion that we see, a new function stack frame
> is being created on the C stack; on this x86_64-pc-linux-gnu system
> running Debian GNU/Linux, in an optimized build, that means 80 bytes
> of stack space are reserved for each level of recursion.
> 
> That number could be much closer to 8, which is the number of bytes of
> relevant data in those 80 bytes of stack space.
> 
> My proposal is to continue allocating the mark queue on the stack (not
> the heap), but to do so in larger chunks, allocating enough space for
> N objects and recursing, in the C sense, only when all N object slots
> have been used.
> 
> In addition to saving stack space, this should also help, at least,
> older systems with limited return address prediction stacks.

FWIW, I'm only interested in changes to GC if they bring significant
gains, such as replacing the mark & sweep algorithm with something
more modern and powerful.  Otherwise, experience shows that messing
with GC for smaller gains is not worth it: it destabilizes Emacs for
no good reason, since users rarely if ever see any significant
improvements.

> In further patches, I'd like to change things so we no longer recurse
> through symbols so enthusiastically, building up tens of thousands of
> objects on the mark queue.

I'd like to hear and understand the long-term plan before I agree to
any such changes.  And in general, I'd like to see the plan
implemented in large steps, not small changes.  We have bad experience
with the latter: over the years there were a couple of attempts to do
it that led nowhere, and we are left with their leftovers that don't
make much sense on their own, and just make the sources harder to read
and understand, let alone change.

So please: no small changes in GC, thank you.

> In the interest of full disclosure, I have several ulterior motives
> for this: the WebAssembly implementation I'm using doesn't allow deep
> nesting of calls; I'd like to look into parallelizing GC for which
> this might be useful; and I suspect native-comp will benefit more from
> further work in this area, too.

If the goal is to make GC parallel, let's first discuss the idea for
how to do it, and (assuming we agree to go that way) let's start with
it, not present it as some long-term goal.

Thanks.





  reply	other threads:[~2021-03-03 16:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-03 15:44 bug#46900: 28.0.50; GC uses excessive amounts of stack Pip Cet
2021-03-03 16:28 ` Eli Zaretskii [this message]
2021-03-04  5:32 ` Richard Stallman
2021-03-04  7:53   ` Pip Cet

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://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=83wnuojj6g.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=46900@debbugs.gnu.org \
    --cc=pipcet@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://git.savannah.gnu.org/cgit/emacs.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).