40 hours agoRevert "NonMovingScav: Account for new allocations" wip/gc/debug
Ben Gamari [Sun, 16 Jun 2019 19:01:30 +0000 (15:01 -0400)] 
Revert "NonMovingScav: Account for new allocations"

This reverts commit ce36fd898436386c13468d41adaf6f11f2e9c7f1.

40 hours agoTracing
Ben Gamari [Sun, 16 Jun 2019 18:07:40 +0000 (14:07 -0400)] 

40 hours agoNonMoving: Clean mut_list
Ben Gamari [Wed, 22 May 2019 01:07:17 +0000 (21:07 -0400)] 
NonMoving: Clean mut_list

40 hours agoWeak debugging
Ben Gamari [Tue, 21 May 2019 22:08:01 +0000 (18:08 -0400)] 
Weak debugging

40 hours agoRevert "XXX: Disable selector optimization and shortcutting"
Ben Gamari [Tue, 21 May 2019 02:12:51 +0000 (22:12 -0400)] 
Revert "XXX: Disable selector optimization and shortcutting"

This reverts commit e1df1b1e24c66fc9e391dfa275ec2e0332b698ac.

40 hours agoNonMovingScav: Account for new allocations
Ben Gamari [Tue, 21 May 2019 00:27:48 +0000 (20:27 -0400)] 
NonMovingScav: Account for new allocations

Previously if we evacuated any objects to the segment that we were
scavenging we would exit the scavenge loop before having scavenged them.
This isn't a correctness issue since we would try again to scavenge
later but it is slightly more efficient to handle newly-allocated
objects ASAP after we allocate them.

40 hours agoXXX: Disable selector optimization and shortcutting
Ben Gamari [Mon, 20 May 2019 22:30:07 +0000 (18:30 -0400)] 
XXX: Disable selector optimization and shortcutting

40 hours agoTrace dump
Ben Gamari [Mon, 20 May 2019 20:12:05 +0000 (16:12 -0400)] 
Trace dump

40 hours agoMore mutlist debugging
Ben Gamari [Mon, 20 May 2019 16:39:12 +0000 (12:39 -0400)] 
More mutlist debugging

40 hours agoNonMoving: Prefetch allocated block for write
Ben Gamari [Sat, 18 May 2019 15:02:10 +0000 (11:02 -0400)] 
NonMoving: Prefetch allocated block for write

This allows us to overlap bringing the block into cache with the search
for the next available block.

40 hours agoNonMoving: Trace swept segment counts
Ben Gamari [Thu, 16 May 2019 14:20:00 +0000 (10:20 -0400)] 
NonMoving: Trace swept segment counts

40 hours agoXXX: trace dump infrastructure
Ben Gamari [Thu, 9 May 2019 21:21:12 +0000 (17:21 -0400)] 
XXX: trace dump infrastructure

40 hours agoXXX: Mark tracing
Ben Gamari [Wed, 8 May 2019 22:36:21 +0000 (18:36 -0400)] 
XXX: Mark tracing

40 hours agoXXX: Unconditionally flush update remembered set during minor GC
Ben Gamari [Thu, 9 May 2019 01:28:35 +0000 (21:28 -0400)] 
XXX: Unconditionally flush update remembered set during minor GC

40 hours agoTracing
Ben Gamari [Thu, 16 May 2019 12:53:20 +0000 (08:53 -0400)] 

40 hours agoXXX: Various tracing
Ben Gamari [Sun, 14 Apr 2019 16:36:59 +0000 (12:36 -0400)] 
XXX: Various tracing

40 hours agoIntroduce MUTLIST_DEBUG
Ben Gamari [Mon, 15 Apr 2019 14:12:53 +0000 (10:12 -0400)] 

40 hours agoXXX: Indirection counting
Ben Gamari [Mon, 22 Apr 2019 15:30:38 +0000 (11:30 -0400)] 
XXX: Indirection counting

40 hours agoXXX: Allow inline SRTs to be easily disabled
Ben Gamari [Sat, 27 Apr 2019 19:56:55 +0000 (15:56 -0400)] 
XXX: Allow inline SRTs to be easily disabled

40 hours agoSanity: Check nonmoving heap sanity after concurrent GC
Ben Gamari [Sat, 27 Apr 2019 19:56:24 +0000 (15:56 -0400)] 
Sanity: Check nonmoving heap sanity after concurrent GC

40 hours agoAdd some lock contention checking
Ben Gamari [Sun, 14 Apr 2019 14:46:40 +0000 (10:46 -0400)] 
Add some lock contention checking

40 hours agoImplement -xns for -xn with selector opt
Ömer Sinan Ağacan [Thu, 16 May 2019 13:28:32 +0000 (16:28 +0300)] 
Implement -xns for -xn with selector opt

40 hours agorts: COMPACT_NFDATA support for the nonmoving collector
Ömer Sinan Ağacan [Thu, 23 May 2019 10:32:42 +0000 (13:32 +0300)] 
rts: COMPACT_NFDATA support for the nonmoving collector

This largely follows the model used for large objects, with appropriate
adjustments made to account for references in the sharing deduplication

40 hours agoMerge branches 'wip/gc/segment-header-to-bdescr' and 'wip/gc/docs' into wip/gc/everyt...
Ben Gamari [Wed, 19 Jun 2019 01:43:19 +0000 (21:43 -0400)] 
Merge branches 'wip/gc/segment-header-to-bdescr' and 'wip/gc/docs' into wip/gc/everything2

40 hours agoNonMoving: More comments
Ben Gamari [Sun, 19 May 2019 18:09:16 +0000 (14:09 -0400)] 
NonMoving: More comments

40 hours agoNonMoving: Add summarizing Note
Ben Gamari [Fri, 17 May 2019 15:42:11 +0000 (11:42 -0400)] 
NonMoving: Add summarizing Note

40 hours agoNonMoving: Move next_free_snap to block descriptor
Ben Gamari [Fri, 17 May 2019 17:38:36 +0000 (13:38 -0400)] 
NonMoving: Move next_free_snap to block descriptor

40 hours agoNonMoving: Move block size to block descriptor
Ben Gamari [Fri, 17 May 2019 17:28:53 +0000 (13:28 -0400)] 
NonMoving: Move block size to block descriptor

40 hours agoNonMoving: Introduce nonmovingSegmentLogBlockSize acccessor
Ben Gamari [Fri, 17 May 2019 17:18:48 +0000 (13:18 -0400)] 
NonMoving: Introduce nonmovingSegmentLogBlockSize acccessor

This will allow us to easily move the block size elsewhere.

40 hours agoNonMoving: Implement selector optimisation
Ömer Sinan Ağacan [Mon, 16 Jul 2018 12:22:29 +0000 (15:22 +0300)] 
NonMoving: Implement selector optimisation

40 hours agoNonMoving: Implement indirection shortcutting
Ömer Sinan Ağacan [Thu, 25 Apr 2019 13:08:13 +0000 (16:08 +0300)] 
NonMoving: Implement indirection shortcutting

This allows indirection chains residing in the non-moving heap to be

40 hours agoMerge branches 'wip/gc/optimize' and 'wip/gc/test' into wip/gc/everything
Ben Gamari [Wed, 19 Jun 2019 01:42:18 +0000 (21:42 -0400)] 
Merge branches 'wip/gc/optimize' and 'wip/gc/test' into wip/gc/everything

40 hours agoNonmoving: Ensure write barrier vanishes in non-threaded RTS
Ben Gamari [Sun, 19 May 2019 17:29:42 +0000 (13:29 -0400)] 
Nonmoving: Ensure write barrier vanishes in non-threaded RTS

40 hours agoNonMoving: Don't do major GC if one is already running
Ben Gamari [Fri, 17 May 2019 23:18:42 +0000 (19:18 -0400)] 
NonMoving: Don't do major GC if one is already running

Previously we would perform a preparatory moving collection, resulting
in many things being added to the mark queue. When we finished with this
we would realize in nonmovingCollect that there was already a collection
running, in which case we would simply not run the nonmoving collector.

However, it was very easy to end up in a "treadmilling" situation: all
subsequent GC following the first failed major GC would be scheduled as
major GCs. Consequently we would continuously feed the concurrent
collector with more mark queue entries and it would never finish.

This patch aborts the major collection far earlier, meaning that we
avoid adding nonmoving objects to the mark queue and allowing the
concurrent collector to finish.

40 hours agoNonMovingMark: Eliminate redundant check_in_nonmoving_heaps
Ben Gamari [Sat, 4 May 2019 00:06:47 +0000 (20:06 -0400)] 
NonMovingMark: Eliminate redundant check_in_nonmoving_heaps

40 hours agoNonMoving: Optimise allocator cache behavior
Ben Gamari [Sun, 12 May 2019 03:04:54 +0000 (23:04 -0400)] 
NonMoving: Optimise allocator cache behavior

Previously we would look at the segment header to determine the block
size despite the fact that we already had the block size at hand.

40 hours agoNonMoving: Prefetch segment header
Ben Gamari [Thu, 16 May 2019 21:14:38 +0000 (17:14 -0400)] 
NonMoving: Prefetch segment header

40 hours agoNonMoving: Pre-fetch during mark
Ben Gamari [Wed, 15 May 2019 20:49:40 +0000 (16:49 -0400)] 
NonMoving: Pre-fetch during mark

This improved overall runtime on nofib's constraints test by nearly 10%.

40 hours agoNonMoving: Fuse sweep preparation into mark prep
Ben Gamari [Sat, 11 May 2019 23:53:46 +0000 (19:53 -0400)] 
NonMoving: Fuse sweep preparation into mark prep

40 hours agoNonMoving: Inline nonmovingClearAllBitmaps
Ben Gamari [Sat, 11 May 2019 23:32:17 +0000 (19:32 -0400)] 
NonMoving: Inline nonmovingClearAllBitmaps

40 hours agoNonMoving: Prefetch when clearing bitmaps
Ben Gamari [Sat, 11 May 2019 23:14:43 +0000 (19:14 -0400)] 
NonMoving: Prefetch when clearing bitmaps

Ensure that the bitmap of the segmentt that we will clear next is in
cache by the time we reach it.

40 hours agorts: Add prefetch macros
Ben Gamari [Sat, 18 May 2019 15:02:03 +0000 (11:02 -0400)] 
rts: Add prefetch macros

40 hours agoNonMoving: Optimize bitmap search during allocation
Ben Gamari [Sat, 11 May 2019 15:55:42 +0000 (11:55 -0400)] 
NonMoving: Optimize bitmap search during allocation

Use memchr instead of a open-coded loop. This is nearly twice as fast in
a synthetic benchmark.

40 hours agoNonMovingMark: Optimize representation of mark queue
Ben Gamari [Fri, 3 May 2019 23:44:54 +0000 (19:44 -0400)] 
NonMovingMark: Optimize representation of mark queue

This shortens MarkQueueEntry by 30% (one word)

40 hours agoAllocate mark queues in larger block groups
Ben Gamari [Sun, 14 Apr 2019 16:26:57 +0000 (12:26 -0400)] 
Allocate mark queues in larger block groups

40 hours agoNonMoving: Eliminate integer division in nonmovingBlockCount
Ben Gamari [Tue, 16 Apr 2019 18:32:40 +0000 (14:32 -0400)] 
NonMoving: Eliminate integer division in nonmovingBlockCount

Perf showed that the this single div was capturing up to 10% of samples
in nonmovingMark. However, the overwhelming majority of cases is looking
at small block sizes. These cases we can easily compute explicitly,
allowing the compiler to turn the division into a significantly more
efficient division-by-constant.

While the increase in source code looks scary, this all optimises down
to very nice looking assembler. At this point the only remaining
hotspots in nonmovingBlockCount are due to memory access.

40 hours agoSkip ghc_heap_all test in nonmoving ways
Ben Gamari [Wed, 3 Apr 2019 00:50:56 +0000 (20:50 -0400)] 
Skip ghc_heap_all test in nonmoving ways

40 hours agoghc-heap: Skip heap_all test with debugged RTS
Ben Gamari [Tue, 5 Mar 2019 00:45:36 +0000 (19:45 -0500)] 
ghc-heap: Skip heap_all test with debugged RTS

The debugged RTS initializes the heap with 0xaa, which breaks the
(admittedly rather fragile) assumption that uninitialized fields are set
to 0x00:
Wrong exit code for heap_all(nonmoving)(expected 0 , actual 1 )
Stderr ( heap_all ):
heap_all: user error (assertClosuresEq: Closures do not match
Expected: FunClosure {info = StgInfoTable {entry = Nothing, ptrs = 0, nptrs = 1, tipe = FUN_0_1, srtlen = 0, code = Nothing}, ptrArgs = [], dataArgs = [0]}
Actual:   FunClosure {info = StgInfoTable {entry = Nothing, ptrs = 0, nptrs = 1, tipe = FUN_0_1, srtlen = 1032832, code = Nothing}, ptrArgs = [], dataArgs = [12297829382473034410]}

CallStack (from HasCallStack):
  assertClosuresEq, called at heap_all.hs:230:9 in main:Main

40 hours agotestsuite: Skip T15892 in nonmoving_thr_ghc
Ben Gamari [Wed, 13 Feb 2019 20:33:31 +0000 (15:33 -0500)] 
testsuite: Skip T15892 in nonmoving_thr_ghc

40 hours agotestsuite: bug1010 requires -c, which isn't supported by nonmoving
Ben Gamari [Wed, 13 Feb 2019 19:05:37 +0000 (14:05 -0500)] 
testsuite: bug1010 requires -c, which isn't supported by nonmoving

40 hours agotestsuite: Ensure that threaded tests are run in nonmoving_thr
Ben Gamari [Wed, 13 Feb 2019 18:49:04 +0000 (13:49 -0500)] 
testsuite: Ensure that threaded tests are run in nonmoving_thr

40 hours agotestsuite: Nonmoving collector doesn't support -G1
Ben Gamari [Tue, 5 Feb 2019 22:15:57 +0000 (17:15 -0500)] 
testsuite: Nonmoving collector doesn't support -G1

40 hours agotestsuite: Don't run T15892 in nonmoving ways
Ben Gamari [Tue, 5 Feb 2019 22:06:25 +0000 (17:06 -0500)] 
testsuite: Don't run T15892 in nonmoving ways

The nonmoving GC doesn't support `+RTS -G1`, which this test insists on.

40 hours agotestsuite: Add nonmoving_thr_ghc way
Ben Gamari [Tue, 12 Feb 2019 03:03:33 +0000 (22:03 -0500)] 
testsuite: Add nonmoving_thr_ghc way

This uses the nonmoving collector when compiling the testcases.

40 hours agotestsuite: Add nonmoving_thr way
Ben Gamari [Tue, 12 Feb 2019 03:03:33 +0000 (22:03 -0500)] 
testsuite: Add nonmoving_thr way

40 hours agoMore comments for aging
Ben Gamari [Tue, 18 Jun 2019 21:22:06 +0000 (17:22 -0400)] 
More comments for aging

40 hours agoDisable aging when doing deadlock detection GC
Ben Gamari [Sun, 16 Jun 2019 16:22:56 +0000 (12:22 -0400)] 
Disable aging when doing deadlock detection GC

40 hours agoNonmoving: Allow aging and refactor static objects logic
Ben Gamari [Thu, 18 Apr 2019 18:08:32 +0000 (14:08 -0400)] 
Nonmoving: Allow aging and refactor static objects logic

This commit does two things:

 * Allow aging of objects during the preparatory minor GC
 * Refactor handling of static objects to avoid the use of a hashtable

40 hours agorts/Stats: Track time usage of nonmoving collector
Ben Gamari [Fri, 3 May 2019 19:15:45 +0000 (15:15 -0400)] 
rts/Stats: Track time usage of nonmoving collector

40 hours agorts: Add GetMyThreadCPUTime helper
Ben Gamari [Fri, 17 May 2019 19:40:26 +0000 (15:40 -0400)] 
rts: Add GetMyThreadCPUTime helper

40 hours agoNonmovingCensus: Emit samples to eventlog
Ben Gamari [Mon, 15 Apr 2019 20:42:56 +0000 (16:42 -0400)] 
NonmovingCensus: Emit samples to eventlog

40 hours agoAllow census without live word count
Ben Gamari [Sat, 16 Mar 2019 14:24:24 +0000 (10:24 -0400)] 
Allow census without live word count

Otherwise the census is unsafe when mutators are running due to
concurrent mutation.

40 hours agorts/Eventlog: More descriptive error message
Ben Gamari [Mon, 15 Apr 2019 21:07:24 +0000 (17:07 -0400)] 
rts/Eventlog: More descriptive error message

40 hours agorts: Introduce non-moving heap census
Ben Gamari [Tue, 5 Feb 2019 16:52:13 +0000 (11:52 -0500)] 
rts: Introduce non-moving heap census

This introduces a simple census of the non-moving heap (not to be
confused with the heap census used by the heap profiler). This
collects basic heap usage information (number of allocated and free
blocks) which is useful when characterising fragmentation of the
nonmoving heap.

40 hours agorts: Tracing support for nonmoving collection events
Ben Gamari [Tue, 5 Feb 2019 16:51:52 +0000 (11:51 -0500)] 
rts: Tracing support for nonmoving collection events

This introduces a few events to mark key points in the nonmoving
garbage collection cycle. These include:

 * `EVENT_CONC_MARK_BEGIN`, denoting the beginning of a round of
   marking. This may happen more than once in a single major collection
   since we the major collector iterates until it hits a fixed point.

 * `EVENT_CONC_MARK_END`, denoting the end of a round of marking.

 * `EVENT_CONC_SYNC_BEGIN`, denoting the beginning of the post-mark
   synchronization phase

 * `EVENT_CONC_UPD_REM_SET_FLUSH`, indicating that a capability has
   flushed its update remembered set.

 * `EVENT_CONC_SYNC_END`, denoting that all mutators have flushed their
   update remembered sets.

 * `EVENT_CONC_SWEEP_BEGIN`, denoting the beginning of the sweep portion
   of the major collection.

 * `EVENT_CONC_SWEEP_END`, denoting the end of the sweep portion of the
   major collection.

40 hours agoNonmoving: Disable memory inventory with concurrent collection
Ben Gamari [Fri, 17 May 2019 02:13:02 +0000 (22:13 -0400)] 
Nonmoving: Disable memory inventory with concurrent collection

40 hours agorts: Implement concurrent collection in the nonmoving collector
Ben Gamari [Tue, 5 Feb 2019 16:51:14 +0000 (11:51 -0500)] 
rts: Implement concurrent collection in the nonmoving collector

This extends the non-moving collector to allow concurrent collection.

The full design of the collector implemented here is described in detail
in a technical note

    B. Gamari. "A Concurrent Garbage Collector For the Glasgow Haskell
    Compiler" (2018)

This extension involves the introduction of a capability-local
remembered set, known as the /update remembered set/, which tracks
objects which may no longer be visible to the collector due to mutation.
To maintain this remembered set we introduce a write barrier on
mutations which is enabled while a concurrent mark is underway.

The update remembered set representation is similar to that of the
nonmoving mark queue, being a chunked array of `MarkEntry`s. Each
`Capability` maintains a single accumulator chunk, which it flushed
when it (a) is filled, or (b) when the nonmoving collector enters its
post-mark synchronization phase.

While the write barrier touches a significant amount of code it is
conceptually straightforward: the mutator must ensure that the referee
of any pointer it overwrites is added to the update remembered set.
However, there are a few details:

 * In the case of objects with a dirty flag (e.g. `MVar`s) we can
   exploit the fact that only the *first* mutation requires a write

 * Weak references, as usual, complicate things. In particular, we must
   ensure that the referee of a weak object is marked if dereferenced by
   the mutator. For this we (unfortunately) must introduce a read
   barrier, as described in Note [Concurrent read barrier on deRefWeak#]
   (in `NonMovingMark.c`).

 * Stable names are also a bit tricky as described in Note [Sweeping
   stable names in the concurrent collector] (`NonMovingSweep.c`).

We take quite some pains to ensure that the high thread count often seen
in parallel Haskell applications doesn't affect pause times. To this end
we allow thread stacks to be marked either by the thread itself (when it
is executed or stack-underflows) or the concurrent mark thread (if the
thread owning the stack is never scheduled). There is a non-trivial
handshake to ensure that this happens without racing which is described
in Note [StgStack dirtiness flags and concurrent marking].

Co-Authored-by: Ömer Sinan Ağacan <>
40 hours agotestsuite: Add nonmoving WAY
Ben Gamari [Tue, 5 Feb 2019 19:39:52 +0000 (14:39 -0500)] 
testsuite: Add nonmoving WAY

This simply runs the compile_and_run tests with `-xn`, enabling the
nonmoving oldest generation.

40 hours agorts: Non-concurrent mark and sweep
Ömer Sinan Ağacan [Tue, 5 Feb 2019 05:18:44 +0000 (00:18 -0500)] 
rts: Non-concurrent mark and sweep

This implements the core heap structure and a serial mark/sweep
collector which can be used to manage the oldest-generation heap.
This is the first step towards a concurrent mark-and-sweep collector
aimed at low-latency applications.

The full design of the collector implemented here is described in detail
in a technical note

    B. Gamari. "A Concurrent Garbage Collector For the Glasgow Haskell
    Compiler" (2018)

The basic heap structure used in this design is heavily inspired by

    K. Ueno & A. Ohori. "A fully concurrent garbage collector for
    functional programs on multicore processors." /ACM SIGPLAN Notices/
    Vol. 51. No. 9 (presented by ICFP 2016)

This design is intended to allow both marking and sweeping
concurrent to execution of a multi-core mutator. Unlike the Ueno design,
which requires no global synchronization pauses, the collector
introduced here requires a stop-the-world pause at the beginning and end
of the mark phase.

To avoid heap fragmentation, the allocator consists of a number of
fixed-size /sub-allocators/. Each of these sub-allocators allocators into
its own set of /segments/, themselves allocated from the block
allocator. Each segment is broken into a set of fixed-size allocation
blocks (which back allocations) in addition to a bitmap (used to track
the liveness of blocks) and some additional metadata (used also used
to track liveness).

This heap structure enables collection via mark-and-sweep, which can be
performed concurrently via a snapshot-at-the-beginning scheme (although
concurrent collection is not implemented in this patch).

The mark queue is a fairly straightforward chunked-array structure.
The representation is a bit more verbose than a typical mark queue to
accomodate a combination of two features:

 * a mark FIFO, which improves the locality of marking, reducing one of
   the major overheads seen in mark/sweep allocators (see [1] for

 * the selector optimization and indirection shortcutting, which
   requires that we track where we found each reference to an object
   in case we need to update the reference at a later point (e.g. when
   we find that it is an indirection). See Note [Origin references in
   the nonmoving collector] (in `NonMovingMark.h`) for details.

Beyond this the mark/sweep is fairly run-of-the-mill.

[1] R. Garner, S.M. Blackburn, D. Frampton. "Effective Prefetch for
    Mark-Sweep Garbage Collection." ISMM 2007.

Co-Authored-By: Ben Gamari <>
41 hours agorts: Introduce debug flag for non-moving GC
Ben Gamari [Sat, 7 Jul 2018 01:02:22 +0000 (21:02 -0400)] 
rts: Introduce debug flag for non-moving GC

41 hours agorts: Introduce flag to enable the nonmoving old generation
Ben Gamari [Tue, 5 Feb 2019 05:10:43 +0000 (00:10 -0500)] 
rts: Introduce flag to enable the nonmoving old generation

This flag will enable the use of a non-moving oldest generation.

41 hours agorts/Scav: Expose scavenging functions
Ömer Sinan Ağacan [Tue, 5 Feb 2019 16:46:25 +0000 (11:46 -0500)] 
rts/Scav: Expose scavenging functions

To keep the non-moving collector nicely separated from the moving
collector its scavenging phase will live in another file,
`NonMovingScav.c`. However, it will need to use these functions so
let's expose them.

41 hours agorts: Disable aggregate-return warnings from gcc
Ben Gamari [Tue, 5 Feb 2019 17:48:29 +0000 (12:48 -0500)] 
rts: Disable aggregate-return warnings from gcc

This warning is a bit of a relic; there is little reason to avoid
aggregate return values in 2019.

41 hours agorts/StableName: Expose FOR_EACH_STABLE_NAME, freeSnEntry, SNT_size
Ömer Sinan Ağacan [Tue, 5 Feb 2019 05:40:27 +0000 (00:40 -0500)] 
rts/StableName: Expose FOR_EACH_STABLE_NAME, freeSnEntry, SNT_size

These will be needed when we implement sweeping in the nonmoving

41 hours agoMerge branches 'wip/gc/misc-rts' and 'wip/gc/aligned-block-allocation' into wip/gc...
Ben Gamari [Wed, 19 Jun 2019 00:32:46 +0000 (20:32 -0400)] 
Merge branches 'wip/gc/misc-rts' and 'wip/gc/aligned-block-allocation' into wip/gc/preparation

41 hours agoAllow allocating megablocks in allocAlignedGroupOnNode
Ömer Sinan Ağacan [Mon, 10 Jun 2019 07:42:41 +0000 (10:42 +0300)] 
Allow allocating megablocks in allocAlignedGroupOnNode

This is currently broken because freeGroup assumes integral number of
megablocks when freeing megablocks but we try to split the megablocks
returned by allocLargeChunkOnNode to smaller groups and free the rest.

41 hours agoUse allocLargeChunkOnNode to reduce splitting
Ömer Sinan Ağacan [Wed, 17 Apr 2019 13:44:56 +0000 (16:44 +0300)] 
Use allocLargeChunkOnNode to reduce splitting

41 hours agoFix lint errors
Ömer Sinan Ağacan [Wed, 10 Apr 2019 12:12:32 +0000 (15:12 +0300)] 
Fix lint errors

41 hours agoDisallow allocating megablocks, update tests
Ömer Sinan Ağacan [Wed, 10 Apr 2019 06:05:18 +0000 (09:05 +0300)] 
Disallow allocating megablocks, update tests

41 hours agorts/BlockAlloc: Use allocLargeChunk in aligned block allocation
Ben Gamari [Mon, 4 Mar 2019 22:20:39 +0000 (17:20 -0500)] 
rts/BlockAlloc: Use allocLargeChunk in aligned block allocation

41 hours agorts/BlockAlloc: Wibbles
Ben Gamari [Mon, 4 Mar 2019 22:20:33 +0000 (17:20 -0500)] 
rts/BlockAlloc: Wibbles

41 hours agotestsuite/testblockalloc: Test aligned block group allocation
Ben Gamari [Mon, 4 Mar 2019 22:12:14 +0000 (17:12 -0500)] 
testsuite/testblockalloc: Test aligned block group allocation

41 hours agotestsuite/testblockalloc: A bit of refactoring
Ben Gamari [Mon, 4 Mar 2019 22:07:20 +0000 (17:07 -0500)] 
testsuite/testblockalloc: A bit of refactoring

41 hours agorts/BlockAlloc: Allow aligned allocation requests
Ömer Sinan Ağacan [Mon, 5 Mar 2018 12:57:47 +0000 (15:57 +0300)] 
rts/BlockAlloc: Allow aligned allocation requests

This implements support for block group allocations which are aligned to
an integral number of blocks.

This will be used by the nonmoving garbage collector, which uses the
block allocator to allocate the segments which back its heap. These
segments are a fixed number of blocks in size, with each segment being
aligned to the segment size boundary. This allows us to easily find the
segment metadata stored at the beginning of the segment.

41 hours agorts: Fix CPP linter issues
Ben Gamari [Tue, 18 Jun 2019 23:19:42 +0000 (19:19 -0400)] 
rts: Fix CPP linter issues

43 hours agorts: Fix macro parenthesisation
Ben Gamari [Wed, 8 May 2019 22:35:26 +0000 (18:35 -0400)] 
rts: Fix macro parenthesisation

43 hours agorts/GC: Refactor gcCAFs
Ben Gamari [Wed, 6 Feb 2019 02:17:36 +0000 (21:17 -0500)] 
rts/GC: Refactor gcCAFs

43 hours agorts: Give stack flags proper macros
Ben Gamari [Tue, 5 Feb 2019 16:01:10 +0000 (11:01 -0500)] 
rts: Give stack flags proper macros

This were previously quite unclear and will change a bit under the
non-moving collector so let's clear this up now.

43 hours agorts/Capability: A few documentation comments
Ben Gamari [Tue, 5 Feb 2019 15:43:56 +0000 (10:43 -0500)] 
rts/Capability: A few documentation comments

43 hours agorts: Add Note explaining applicability of selector optimisation depth limit
Ben Gamari [Tue, 3 Jul 2018 23:58:37 +0000 (19:58 -0400)] 
rts: Add Note explaining applicability of selector optimisation depth limit

This was slightly non-obvious so a note seems deserved.

43 hours agorts/GC: Add an obvious assertion during block initialization
Ömer Sinan Ağacan [Tue, 5 Feb 2019 15:40:29 +0000 (10:40 -0500)] 
rts/GC: Add an obvious assertion during block initialization

Namely ensure that block descriptors are initialized with valid
generation numbers.

43 hours agorts/Schedule: Allow synchronization without holding a capability wip/gc/sync-without-capability
Ben Gamari [Fri, 20 Jul 2018 01:57:14 +0000 (21:57 -0400)] 
rts/Schedule: Allow synchronization without holding a capability

The concurrent mark-and-sweep will be performed by a GHC task which will
not hold a capability. This is necessary to avoid a concurrent mark from
interfering with minor generation collections.

However, the major collector must synchronize with the mutators at the
end of marking to flush their update remembered sets. This patch extends
the `requestSync` mechanism used to synchronize garbage collectors to
allow synchronization without holding a capability.

This change is fairly straightforward as the capability was previously
only required for two reasons:

 1. to ensure that we don't try to re-acquire a capability that we
    the sync requestor already holds.

 2. to provide a way to suspend and later resume the sync request if
    there is already a sync pending.

When synchronizing without holding a capability we needn't worry about
consideration (1) at all.

(2) is slightly trickier and may happen, for instance, when a capability
requests a minor collection and shortly thereafter the non-moving mark
thread requests a post-mark synchronization. In this case we need to
ensure that the non-moving mark thread suspends his request until after
the minor GC has concluded to avoid dead-locking. For this we introduce
a condition variable, `sync_finished_cond`, which a
non-capability-bearing requestor will wait on and which is signalled
after a synchronization or GC has finished.

3 days agoAdd link to in wip/gc/base wip/gc/factor-out-bitmap-walking wip/gc/printer-improvements wip/gc/unglobalize-gc-state
Siddharth Bhat [Sun, 16 Jun 2019 12:36:24 +0000 (14:36 +0200)] 
Add link to in

3 days agomake: Clean includes/settings file
Ben Gamari [Fri, 14 Jun 2019 21:23:20 +0000 (17:23 -0400)] 
make: Clean includes/settings file

Now since this is generated by the build system we should ensure that it
is properly cleaned.

[skip ci]

3 days agoUse TupleSections in CmmParse.y, simplify a few exprs
Ömer Sinan Ağacan [Sun, 16 Jun 2019 07:09:49 +0000 (10:09 +0300)] 
Use TupleSections in CmmParse.y, simplify a few exprs

3 days agogitlab-ci: Don't allow failure of deb9-dwarf job
Ben Gamari [Fri, 14 Jun 2019 02:53:37 +0000 (22:53 -0400)] 
gitlab-ci: Don't allow failure of deb9-dwarf job

This #16741 out of the way this should now pass.

3 days agotestsuite: Really fix #16741
Ben Gamari [Fri, 14 Jun 2019 02:51:53 +0000 (22:51 -0400)] 
testsuite: Really fix #16741

The previous fix, !1095, didn't work as `--show-iface` ignores
`-dsuppress-ticks`. Rework the test instead.

4 days agofix runghc's GHC detection logic to cover the "in-tree Hadrian build" scenario
Alp Mestanogullari [Fri, 14 Jun 2019 19:28:31 +0000 (21:28 +0200)] 
fix runghc's GHC detection logic to cover the "in-tree Hadrian build" scenario

Before this patch, runghc would only run the GHC detection logic on Windows and
assume that it was invoked through a wrapper script on all other platforms.
This patch lifts this limitation and makes that logic work for the scenario
where someone is calling the runghc executable directly, without passing an
explicit path to GHC.

4 days agogitlab-ci: Build alpine release bindists
Ben Gamari [Tue, 11 Jun 2019 01:00:57 +0000 (21:00 -0400)] 
gitlab-ci: Build alpine release bindists

4 days agotestsuite: Ensure that ffi005 output order is predictable
Ben Gamari [Tue, 11 Jun 2019 17:09:55 +0000 (13:09 -0400)] 
testsuite: Ensure that ffi005 output order is predictable

The libc output buffer wasn't being flushed, making the order