-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate binary log files from the RTS containing a log of runtime events with timestamps. The log file can be visualised in various ways, for investigating runtime behaviour and debugging performance problems. See for example the forthcoming ThreadScope viewer. New GHC option: -eventlog (link-time option) Enables event logging. +RTS -l (runtime option) Generates <prog>.eventlog with the binary event information. This replaces some of the tracing machinery we already had in the RTS: e.g. +RTS -vg for GC tracing (we should do this using the new event logging instead). Event logging has almost no runtime cost when it isn't enabled, though in the future we might add more fine-grained events and this might change; hence having a link-time option and compiling a separate version of the RTS for event logging. There's a small runtime cost for enabling event-logging, for most programs it shouldn't make much difference. (Todo: docs)
- Loading branch information
Showing
20 changed files
with
809 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
/* ----------------------------------------------------------------------------- | ||
* | ||
* (c) The GHC Team, 2008-2009 | ||
* | ||
* Event log format | ||
* | ||
* The log format is designed to be extensible: old tools should be | ||
* able to parse (but not necessarily understand all of) new versions | ||
* of the format, and new tools will be able to understand old log | ||
* files. | ||
* | ||
* Each event has a specific format. If you add new events, give them | ||
* new numbers: we never re-use old event numbers. | ||
* | ||
* - The format is endian-independent: all values are represented in | ||
* bigendian order. | ||
* | ||
* - The format is extensible: | ||
* | ||
* - The header describes each event type and its length. Tools | ||
* that don't recognise a particular event type can skip those events. | ||
* | ||
* - There is room for extra information in the event type | ||
* specification, which can be ignored by older tools. | ||
* | ||
* - Events can have extra information added, but existing fields | ||
* cannot be changed. Tools should ignore extra fields at the | ||
* end of the event record. | ||
* | ||
* - Old event type ids are never re-used; just take a new identifier. | ||
* | ||
* | ||
* The format | ||
* ---------- | ||
* | ||
* log : EVENT_HEADER_BEGIN | ||
* EventType* | ||
* EVENT_HEADER_END | ||
* EVENT_DATA_BEGIN | ||
* Event* | ||
* EVENT_DATA_END | ||
* | ||
* EventType : | ||
* EVENT_ET_BEGIN | ||
* Word16 -- unique identifier for this event | ||
* Int16 -- >=0 size of the event in bytes (minus the header) | ||
* -- -1 variable size | ||
* Word32 -- length of the next field in bytes | ||
* Word8* -- string describing the event | ||
* Word32 -- length of the next field in bytes | ||
* Word8* -- extra info (for future extensions) | ||
* EVENT_ET_END | ||
* | ||
* Event : | ||
* Word16 -- event_type | ||
* Word64 -- time (nanosecs) | ||
* [Word16] -- length of the rest (for variable-sized events only) | ||
* ... extra event-specific info ... | ||
* | ||
* | ||
* To add a new event | ||
* ------------------ | ||
* | ||
* - In this file: | ||
* - give it a new number, add a new #define EVENT_XXX below | ||
* - In EventLog.c | ||
* - add it to the EventDesc array | ||
* - emit the event type in initEventLogging() | ||
* - emit the new event in postEvent_() | ||
* - generate the event itself by calling postEvent() somewhere | ||
* - In the Haskell code to parse the event log file: | ||
* - add types and code to read the new event | ||
* | ||
* -------------------------------------------------------------------------- */ | ||
|
||
/* | ||
* Markers for begin/end of the Header. | ||
*/ | ||
#define EVENT_HEADER_BEGIN 0x68647262 /* 'h' 'd' 'r' 'b' */ | ||
#define EVENT_HEADER_END 0x68647265 /* 'h' 'd' 'r' 'e' */ | ||
|
||
#define EVENT_DATA_BEGIN 0x64617462 /* 'd' 'a' 't' 'b' */ | ||
#define EVENT_DATA_END 0xffff | ||
|
||
/* | ||
* Markers for begin/end of the list of Event Types in the Header. | ||
* Header, Event Type, Begin = hetb | ||
* Header, Event Type, End = hete | ||
*/ | ||
#define EVENT_HET_BEGIN 0x68657462 /* 'h' 'e' 't' 'b' */ | ||
#define EVENT_HET_END 0x68657465 /* 'h' 'e' 't' 'e' */ | ||
|
||
#define EVENT_ET_BEGIN 0x65746200 /* 'e' 't' 'b' 0 */ | ||
#define EVENT_ET_END 0x65746500 /* 'e' 't' 'e' 0 */ | ||
|
||
/* | ||
* Types of event | ||
*/ | ||
#define EVENT_CREATE_THREAD 0 /* (cap, thread) */ | ||
#define EVENT_RUN_THREAD 1 /* (cap, thread) */ | ||
#define EVENT_STOP_THREAD 2 /* (cap, thread, status) */ | ||
#define EVENT_THREAD_RUNNABLE 3 /* (cap, thread) */ | ||
#define EVENT_MIGRATE_THREAD 4 /* (cap, thread, new_cap) */ | ||
#define EVENT_RUN_SPARK 5 /* (cap, thread) */ | ||
#define EVENT_STEAL_SPARK 6 /* (cap, thread, victim_cap) */ | ||
#define EVENT_SHUTDOWN 7 /* (cap) */ | ||
#define EVENT_THREAD_WAKEUP 8 /* (cap, thread, other_cap) */ | ||
#define EVENT_GC_START 9 /* (cap) */ | ||
#define EVENT_GC_END 10 /* (cap) */ | ||
#define EVENT_REQUEST_SEQ_GC 11 /* (cap) */ | ||
#define EVENT_REQUEST_PAR_GC 12 /* (cap) */ | ||
|
||
#define NUM_EVENT_TAGS 13 | ||
|
||
/* | ||
* Status values for EVENT_STOP_THREAD | ||
* | ||
* 1-5 are the StgRun return values (from includes/Constants.h): | ||
* | ||
* #define HeapOverflow 1 | ||
* #define StackOverflow 2 | ||
* #define ThreadYielding 3 | ||
* #define ThreadBlocked 4 | ||
* #define ThreadFinished 5 | ||
*/ | ||
#define THREAD_SUSPENDED_FOREIGN_CALL 6 | ||
|
||
#ifndef EVENTLOG_CONSTANTS_ONLY | ||
|
||
typedef StgWord16 EventTypeNum; | ||
typedef StgWord64 Timestamp; // in nanoseconds | ||
typedef StgWord64 ThreadID; | ||
typedef StgWord16 CapabilityNum; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.