unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#46900: 28.0.50; GC uses excessive amounts of stack
@ 2021-03-03 15:44 Pip Cet
  2021-03-03 16:28 ` Eli Zaretskii
  2021-03-04  5:32 ` Richard Stallman
  0 siblings, 2 replies; 4+ messages in thread
From: Pip Cet @ 2021-03-03 15:44 UTC (permalink / raw)
  To: 46900

This is a long-standing issue.

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.

IMHO, it would also help, not hinder, debugging of GC internals, as
more context would be available in the function frame. Indeed, the
patch I will send once this has a bug number keeps all of the large
"soft" stack frames in a linked list so we can easily walk them.

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.

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.





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-03-04  7:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2021-03-04  5:32 ` Richard Stallman
2021-03-04  7:53   ` Pip Cet

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).