diff options
author | Simon Marlow <marlowsd@gmail.com> | 2015-02-11 14:19:21 +0000 |
---|---|---|
committer | Simon Marlow <marlowsd@gmail.com> | 2017-11-16 13:49:05 +0000 |
commit | 2f4638735ad1526d6502a4706bffafffb93e24da (patch) | |
tree | 8711e34b498ea52d0a8092fb763892c07c602d92 /includes | |
parent | 07ac921f48baea84b40835b0b7c476806f7f63f6 (diff) | |
download | haskell-2f4638735ad1526d6502a4706bffafffb93e24da.tar.gz |
Detect overly long GC sync
Summary:
GC sync is the time between a GC being intiated and all the mutator
threads finally stopping so that the GC can start. Problems that cause
the GC sync to be delayed are hard to find and can cause dramatic
slowdowns for heavily parallel programs.
The new flag --long-gc-sync=<time> helps by emitting a warning and
calling a user-overridable hook when the GC sync time exceeds the
specified threshold. A debugger can be used to set a breakpoint when
this happens and inspect the stacks of threads to find the culprit.
Test Plan:
```
$ ./inplace/bin/ghc-stage2 +RTS --long-gc-sync=0.0000001 -S
Alloc Copied Live GC GC TOT TOT Page Flts
bytes bytes bytes user elap user elap
1135856 51144 153736 0.000 0.000 0.002 0.002 0 0 (Gen: 0)
1034760 94704 188752 0.000 0.000 0.002 0.002 0 0 (Gen: 0)
1038888 134832 228888 0.009 0.009 0.011 0.011 0 0 (Gen: 1)
1025288 90128 235184 0.000 0.000 0.012 0.012 0 0 (Gen: 0)
1049088 130080 333984 0.000 0.000 0.013 0.013 0 0 (Gen: 0)
Warning: waited 0us for GC sync
1034424 73360 331976 0.000 0.000 0.013 0.013 0 0 (Gen: 0)
```
Also tested on a real production problem.
Reviewers: niteria, bgamari, erikd
Subscribers: rwbarton, thomie
Differential Revision: https://phabricator.haskell.org/D4193
Diffstat (limited to 'includes')
-rw-r--r-- | includes/RtsAPI.h | 4 | ||||
-rw-r--r-- | includes/rts/Flags.h | 2 |
2 files changed, 6 insertions, 0 deletions
diff --git a/includes/RtsAPI.h b/includes/RtsAPI.h index ca61328b7c..27a5080220 100644 --- a/includes/RtsAPI.h +++ b/includes/RtsAPI.h @@ -102,6 +102,10 @@ typedef struct { // Called for every GC void (* gcDoneHook) (const struct GCDetails_ *stats); + + // Called when GC sync takes too long (+RTS --long-gc-sync=<time>) + void (* longGCSync) (uint32_t this_cap, Time time_ns); + void (* longGCSyncEnd) (Time time_ns); } RtsConfig; // Clients should start with defaultRtsConfig and then customise it. diff --git a/includes/rts/Flags.h b/includes/rts/Flags.h index ff45bd378f..aed4dca384 100644 --- a/includes/rts/Flags.h +++ b/includes/rts/Flags.h @@ -65,6 +65,8 @@ typedef struct _GC_FLAGS { Time idleGCDelayTime; /* units: TIME_RESOLUTION */ bool doIdleGC; + Time longGCSync; /* units: TIME_RESOLUTION */ + StgWord heapBase; /* address to ask the OS for memory */ StgWord allocLimitGrace; /* units: *blocks* |