unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
* bug#39361: continuation and gc performance
       [not found] <CAGua6m1DQ+=VoypegHmcAELrHVb-s=DymVv6nMJQoj7aN9=EuA@mail.gmail.com>
@ 2020-01-30 21:10 ` Stefan Israelsson Tampe
  2020-03-21 17:33   ` Ludovic Courtès
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Israelsson Tampe @ 2020-01-30 21:10 UTC (permalink / raw)
  To: 39361

[-- Attachment #1: Type: text/plain, Size: 985 bytes --]

I think I found a gc leak in guile 3.0

Isn't it so that so the continuation keep a copy of the stack. The issue is
that in the stack a raw integer or float may be present and so the gc
properties is less then ideal as those may be interpreted as pointers by
the GC and lead to parts of the heap being kept from garnage collecting.

The information about a slot being a raw value or a scm value is
available as we do the correct gc updating of the stack inside guile 3.0.
May I propose that we add a bitvector to the continuation that indicate
that if a lslot is raw or not. Then add a pass that collect the rawness
information in the creation of the closure. Finally a custom made mark
procedure for closures can be made that uses all this information to make
sure to mark only scm slots in the stored continuation therby improving gc
perfromance.

With this information it would also be possible to serialize continuations
even if they have slots that are raw values.

Happy Hacking

[-- Attachment #2: Type: text/html, Size: 1231 bytes --]

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

* bug#39361: continuation and gc performance
  2020-01-30 21:10 ` bug#39361: continuation and gc performance Stefan Israelsson Tampe
@ 2020-03-21 17:33   ` Ludovic Courtès
  2020-03-21 20:43     ` Stefan Israelsson Tampe
  0 siblings, 1 reply; 4+ messages in thread
From: Ludovic Courtès @ 2020-03-21 17:33 UTC (permalink / raw)
  To: Stefan Israelsson Tampe; +Cc: 39361

Hi Stefan,

Stefan Israelsson Tampe <stefan.itampe@gmail.com> skribis:

> I think I found a gc leak in guile 3.0
>
> Isn't it so that so the continuation keep a copy of the stack. The issue is
> that in the stack a raw integer or float may be present and so the gc
> properties is less then ideal as those may be interpreted as pointers by
> the GC and lead to parts of the heap being kept from garnage collecting.
>
> The information about a slot being a raw value or a scm value is
> available as we do the correct gc updating of the stack inside guile 3.0.
> May I propose that we add a bitvector to the continuation that indicate
> that if a lslot is raw or not. Then add a pass that collect the rawness
> information in the creation of the closure. Finally a custom made mark
> procedure for closures can be made that uses all this information to make
> sure to mark only scm slots in the stored continuation therby improving gc
> perfromance.

I believe what you describe is already what happens in
‘scm_i_vm_mark_stack’.  Or am I missing something?

Thanks,
Ludo’.





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

* bug#39361: continuation and gc performance
  2020-03-21 17:33   ` Ludovic Courtès
@ 2020-03-21 20:43     ` Stefan Israelsson Tampe
  2020-03-22 20:51       ` Ludovic Courtès
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Israelsson Tampe @ 2020-03-21 20:43 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 39361

[-- Attachment #1: Type: text/plain, Size: 1360 bytes --]

That function marks the working stack no, what about stack segments in
continuations will they be marked correctly as well?

On Sat, Mar 21, 2020 at 6:33 PM Ludovic Courtès <ludo@gnu.org> wrote:

> Hi Stefan,
>
> Stefan Israelsson Tampe <stefan.itampe@gmail.com> skribis:
>
> > I think I found a gc leak in guile 3.0
> >
> > Isn't it so that so the continuation keep a copy of the stack. The issue
> is
> > that in the stack a raw integer or float may be present and so the gc
> > properties is less then ideal as those may be interpreted as pointers by
> > the GC and lead to parts of the heap being kept from garnage collecting.
> >
> > The information about a slot being a raw value or a scm value is
> > available as we do the correct gc updating of the stack inside guile 3.0.
> > May I propose that we add a bitvector to the continuation that indicate
> > that if a lslot is raw or not. Then add a pass that collect the rawness
> > information in the creation of the closure. Finally a custom made mark
> > procedure for closures can be made that uses all this information to make
> > sure to mark only scm slots in the stored continuation therby improving
> gc
> > perfromance.
>
> I believe what you describe is already what happens in
> ‘scm_i_vm_mark_stack’.  Or am I missing something?
>
> Thanks,
> Ludo’.
>

[-- Attachment #2: Type: text/html, Size: 1789 bytes --]

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

* bug#39361: continuation and gc performance
  2020-03-21 20:43     ` Stefan Israelsson Tampe
@ 2020-03-22 20:51       ` Ludovic Courtès
  0 siblings, 0 replies; 4+ messages in thread
From: Ludovic Courtès @ 2020-03-22 20:51 UTC (permalink / raw)
  To: Stefan Israelsson Tampe; +Cc: 39361

Hi,

Stefan Israelsson Tampe <stefan.itampe@gmail.com> skribis:

> That function marks the working stack no, what about stack segments in
> continuations will they be marked correctly as well?

Oh you’re right, from a quick look at continuations.c, a continuation’s
stack appears to be conservatively scanned (allocated with
‘scm_gc_malloc’).

My intuition is that it’s “good enough” in most cases, but could affect
GC performance a tiny bit in continuation-heavy code, such as Fibers.

Ludo’.





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

end of thread, other threads:[~2020-03-22 20:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAGua6m1DQ+=VoypegHmcAELrHVb-s=DymVv6nMJQoj7aN9=EuA@mail.gmail.com>
2020-01-30 21:10 ` bug#39361: continuation and gc performance Stefan Israelsson Tampe
2020-03-21 17:33   ` Ludovic Courtès
2020-03-21 20:43     ` Stefan Israelsson Tampe
2020-03-22 20:51       ` Ludovic Courtès

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