1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-18 18:40:22 +02:00
Commit graph

41 commits

Author SHA1 Message Date
Andy Wingo
f51e969730 Use atomics when sweeping
Otherwise, there is a race with concurrent marking, though possibly just
during the ragged stop.
2022-05-01 16:23:10 +02:00
Andy Wingo
2a68dadf22 Accelerate sweeping
Read a word at a time from the mark byte array.  If the mark word
doesn't correspond to live data there will be no contention and we can
clear it with one write.
2022-05-01 16:09:20 +02:00
Andy Wingo
ce69e9ed4c Record object sizes in metadata byte array
This will let us avoid paging in objects when sweeping.
2022-05-01 15:19:13 +02:00
Andy Wingo
3a04078044 mark-sweep uses all the metadata bits
Don't require that mark bytes be cleared; instead we have rotating
colors.  Beginnings of support for concurrent marking, pinning,
conservative roots, and generational collection.
2022-05-01 15:04:21 +02:00
Andy Wingo
f97906421e Sweep by block, not by slab
This lets mutators run in parallel.  There is a bug currently however
with a race between stopping mutators marking their roots and other
mutators still sweeping.  Will fix in a followup.
2022-05-01 14:46:36 +02:00
Andy Wingo
83bf1d8cf3 Fix bug ensuring zeroed memory
If the granule size is bigger than a pointer, we were leaving the first
granule uncleared.
2022-05-01 14:45:25 +02:00
Andy Wingo
7fc2fdbbf7 Use block-structured heap for mark-sweep
There are 4 MB aligned slabs, divided into 64 KB pages.  (On 32-bit this
will be 2 MB ad 32 kB).  Then you can get a mark byte per granule by
slab plus granule offset.  The unused slack that would correspond to
mark bytes for the blocks used *by* the mark bytes is used for other
purposes: remembered sets (not yet used), block summaries (not used),
and a slab header (likewise).
2022-04-27 22:31:09 +02:00
Andy Wingo
bea9ce883d mark-sweep collector uses 16 byte granules, packed small freelists
Probably the collector should use 8 byte granules on 32-bit but for now
we're working on 64-bit sizes.  Since we don't (and never did) pack
pages with same-sized small objects, no need to make sure that small
object sizes fit evenly into the medium object threshold; just keep
packed freelists.  This is a simplification that lets us reclaim the
tail of a region in constant time rather than looping through the size
classes.
2022-04-20 10:54:19 +02:00
Andy Wingo
adc4a7a269 Add large object space to mark-sweep collector
This will let us partition the mark space into chunks of 32 or 64 kB, as
we won't need to allocate chunk-spanning objects.  This will improve
sweeping parallelism and is a step on the way to immix.
2022-04-18 21:20:00 +02:00
Andy Wingo
3ee2009de9 Move a lot of mark_space state to heap 2022-04-18 20:56:48 +02:00
Andy Wingo
119e273fa4 Rename mark-sweep "markers" to "tracers"
There could be other reasons than marking to trace the heap.
2022-04-18 15:19:55 +02:00
Andy Wingo
19f7f72b68 Rename mark-sweep "large" objects to "medium" 2022-04-18 10:00:44 +02:00
Andy Wingo
a1dbbfd6ae Speed up sweeping for small objects
When sweeping for small objects of a known size, instead of fitting
swept regions into the largest available bucket size, eagerly break
the regions into the requested size.  Throw away any fragmented space;
the next collection will get it.

When allocating small objects, just look in the size-segmented freelist;
don't grovel in other sizes on the global freelist.  The thought is that
we only add to the global freelists when allocating large objects, and
in that case some fragmentation is OK.  Perhaps this is the wrong
dynamic.

Reclaim 32 kB at a time instead of 1 kB.  This helps remove scalability
bottlenecks.
2022-03-30 23:15:29 +02:00
Andy Wingo
6300203738 Add call_without_gc API
This lets us call pthread_join safely
2022-03-29 21:58:52 +02:00
Andy Wingo
680032fa89 Minor stop-the-world optimizations. There are still bugs
Probably should switch to using a semaphore; no need to reacquire the
lock on wakeup.
2022-03-29 15:47:19 +02:00
Andy Wingo
d879a01913 Remove gcbench in favor of mt-gcbench. Update quads 2022-03-29 15:12:56 +02:00
Andy Wingo
e837d51f53 mark-sweep collector allows parallel mutators 2022-03-29 15:12:56 +02:00
Andy Wingo
14529f11e9 mark-sweep: add global small object freelist
This will be useful to collect data when sweeping, if a mutator doesn't
need those objects.
2022-03-29 15:11:56 +02:00
Andy Wingo
2d1e76eccc mark-sweep: remote markers can send roots via mark buffers
When you have multiple mutators -- perhaps many more than marker threads
-- they can mark their roots in parallel but they can't enqueue them on
the same mark queue concurrently -- mark queues are single-producer,
multiple-consumer queues.  Therefore, mutator threads will collect grey
roots from their own root sets, and then send them to the mutator that
is controlling GC, for it to add to the mark queue (somehow).
2022-03-29 15:07:59 +02:00
Andy Wingo
be90f7ba49 mark-sweep: Remove context, use mark space instead
This is the end of a series of refactors before adding thread-local
allocation.
2022-03-29 15:07:32 +02:00
Andy Wingo
9b0bc6e975 mark-sweep: Update markers to deal in heap and spaces
This will let us get rid of "struct context".
2022-03-29 15:06:28 +02:00
Andy Wingo
2401732e31 mark-sweep: mutator data structure separate from heap
This will allow thread-local allocation buffers.
2022-03-29 15:05:59 +02:00
Andy Wingo
61d38e4205 Refactor mark-sweep to send mutator to collect()
This will let the mutator hold a pointer to the heap.
2022-03-29 15:05:33 +02:00
Andy Wingo
edd46d8fe2 Start to adapt mark-sweep collector for separate heap/mutator
The current hack is that the mutator contains the heap.  We'll relax
later on.
2022-03-29 15:04:53 +02:00
Andy Wingo
883a761775 Stub out support for multiple mutator threads on semi, mark-sweep
For semi probably we never implement support for multiple mutator
threads.  We will do local freelists for mark-sweep though.
2022-03-20 21:03:26 +01:00
Andy Wingo
32ddaa7624 Allocate GC context in GC-managed heap 2022-03-16 21:31:51 +01:00
Andy Wingo
e7a3f83bcc Add quads benchmark
Also expand GC interface with "allocate_pointerless".  Limit lazy
sweeping to the allocation size that is causing the sweep, without
adding to fragmentation.
2022-03-16 14:16:22 +01:00
Andy Wingo
a693c4ea8a Bugfix to mark-sweep
Before this, the last sweep would cause premature gc
2022-03-13 21:45:20 +01:00
Andy Wingo
7ce07de670 First crack at parallel marking 2022-03-12 21:09:17 +01:00
Andy Wingo
9c89672c88 Put a local mark queue in front of the work-stealing queue 2022-03-11 11:57:14 +01:00
Andy Wingo
df9edfdff2 Remove tiny objects from mark-sweep 2022-03-11 11:48:26 +01:00
Andy Wingo
f57a1b8a55 Refactor to separate gcbench from gc 2022-03-11 11:48:26 +01:00
Andy Wingo
77ac530360 Add beginnings of parallel marker 2022-03-11 11:48:26 +01:00
Andy Wingo
01d3f9627e Further accelerate sweeping 2022-03-11 11:48:17 +01:00
Andy Wingo
5edc4fa81a More efficient sweep 2022-03-11 11:44:11 +01:00
Andy Wingo
5c8a8a2d3e Store mark bits on the side
Lets the sweeper avoid chasing pointers, and is more amenable to
parallel marking.
2022-03-11 11:23:58 +01:00
Andy Wingo
91a330e310 More asserts in mark-sweep 2022-03-11 11:23:58 +01:00
Andy Wingo
c612ff3825 Optimize computation of size class from small object granule count 2022-03-11 11:23:58 +01:00
Andy Wingo
d2828975a5 Switch mark-sweep collector to mark stack
Slows down performance though!  Have to think here.
2022-03-11 11:23:58 +01:00
Andy Wingo
502c0455a7 Fix mark-sweep allocator to clear contents 2022-03-11 11:23:43 +01:00
Andy Wingo
7b85284a89 Add mark-sweep collector 2022-03-07 10:23:05 +01:00