diff options
Diffstat (limited to 'rts/hooks')
-rw-r--r-- | rts/hooks/Hooks.h | 2 | ||||
-rw-r--r-- | rts/hooks/LongGCSync.c | 41 |
2 files changed, 43 insertions, 0 deletions
diff --git a/rts/hooks/Hooks.h b/rts/hooks/Hooks.h index 760e1daefc..24500f19e7 100644 --- a/rts/hooks/Hooks.h +++ b/rts/hooks/Hooks.h @@ -22,5 +22,7 @@ extern void StackOverflowHook (W_ stack_size); extern void OutOfHeapHook (W_ request_size, W_ heap_size); extern void MallocFailHook (W_ request_size /* in bytes */, const char *msg); extern void FlagDefaultsHook (void); +extern void LongGCSync (uint32_t capno, Time t); +extern void LongGCSyncEnd (Time t); #include "EndPrivate.h" diff --git a/rts/hooks/LongGCSync.c b/rts/hooks/LongGCSync.c new file mode 100644 index 0000000000..351406df98 --- /dev/null +++ b/rts/hooks/LongGCSync.c @@ -0,0 +1,41 @@ +/* ----------------------------------------------------------------------------- + * + * User-overridable RTS hooks. + * + * ---------------------------------------------------------------------------*/ + +#include "PosixSource.h" +#include "Rts.h" +#include "sm/GC.h" +#include "sm/GCThread.h" +#include "Hooks.h" + +/* + * Called when --long-gc-sync=<time> has expired during a GC sync. The idea is + * that you can set a breakpoint on this function in gdb and try to determine + * which thread was holding up the GC sync. + */ +void LongGCSync (uint32_t me USED_IF_THREADS, Time t STG_UNUSED) +{ +#if defined(THREADED_RTS) + { + uint32_t i; + for (i=0; i < n_capabilities; i++) { + if (i != me && gc_threads[i]->wakeup != GC_THREAD_STANDING_BY) { + debugBelch("Warning: slow GC sync: still waiting for cap %d\n", + i); + } + } + } +#endif +} + +/* + * Called at the end of a GC sync which was longer than --long-gc-sync=<time>. + * The idea is that you can use this function to log stats about the length of + * GC syncs. + */ +void LongGCSyncEnd (Time t) +{ + debugBelch("Warning: waited %" FMT_Word64 "us for GC sync\n", TimeToUS(t)); +} |