summaryrefslogtreecommitdiff
path: root/rts/Trace.c
Commit message (Collapse)AuthorAgeFilesLines
* Add HEAP_PROF_SAMPLE_END event to mark end of samplesMatthew Pickering2019-06-071-0/+7
| | | | | | | This allows a user to observe how long a sampling period lasts so that the time taken can be removed from the profiling output. Fixes #16697
* eventlog: Log the current stack size when stack overflowsMatthew Pickering2018-11-191-0/+5
| | | | | | | | | | Reviewers: maoe, bgamari, erikd, simonmar Reviewed By: simonmar Subscribers: rwbarton, carter, sjorn3 Differential Revision: https://phabricator.haskell.org/D5287
* rts: Stop tracing environment variables (fixes #15371)Mitsutoshi Aoe2018-10-141-10/+0
| | | | | | | | | | | | | | | | Summary: This tracing may cause a security issue as some external tools out there expects user to set credentials in environment variables. Reviewers: bgamari, erikd, simonmar, monoidal Reviewed By: monoidal Subscribers: tdammers, rwbarton, carter GHC Trac Issues: #15371 Differential Revision: https://phabricator.haskell.org/D5187
* Add traceBinaryEvent# primopMitsutoshi Aoe2018-08-211-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds a new primop called traceBinaryEvent# that takes the length of binary data and a pointer to the data, then emits it to the eventlog. There is some example code that uses this primop and the new event: * [traceBinaryEventIO][1] that calls `traceBinaryEvent#` * [A patch to ghc-events][2] that parses the new `EVENT_USER_BINARY_MSG` There's no corresponding issue on Trac but it was discussed at ghc-devs [3]. [1] https://github.com/maoe/ghc-trace-events/blob /fb226011ef1f85a97b4da7cc9d5f98f9fe6316ae/src/Debug/Trace/Binary.hs#L29) [2] https://github.com/maoe/ghc-events/commit /239ca77c24d18cdd10d6d85a0aef98e4a7c56ae6) [3] https://mail.haskell.org/pipermail/ghc-devs/2018-May/015791.html Reviewers: bgamari, erikd, simonmar Reviewed By: bgamari Subscribers: rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D5007
* rts: Flush eventlog in hs_init_ghc (fixes #15440)Mitsutoshi Aoe2018-07-271-0/+7
| | | | | | | | | | | | | | | Without this change RTS typically doesn't flush some important events until the process terminates or it doesn't write them at all in case it terminates abnormally. Here is a list of such events: * EVENT_WALL_CLOCK_TIME * EVENT_OS_PROCESS_PID * EVENT_OS_PROCESS_PPID * EVENT_RTS_IDENTIFIER * EVENT_PROGRAM_ARGS * EVENT_PROGRAM_ENV
* Fix Work Balance computation in RTS statsDouglas Wilson2017-07-111-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | An additional stat is tracked per gc: par_balanced_copied This is the the number of bytes copied by each gc thread under the balanced lmit, which is simply (copied_bytes / num_gc_threads). The stat is added to all the appropriate GC structures, so is visible in the eventlog and in GHC.Stats. A note is added explaining how work balance is computed. Remove some end of line whitespace Test Plan: ./validate experiment with the program attached to the ticket examine code changes carefully Reviewers: simonmar, austin, hvr, bgamari, erikd Reviewed By: simonmar Subscribers: Phyx, rwbarton, thomie GHC Trac Issues: #13830 Differential Revision: https://phabricator.haskell.org/D3658
* Prefer #if defined to #ifdefBen Gamari2017-04-281-33/+33
| | | | Our new CPP linter enforces this.
* Typos [ci skip]Gabor Greif2017-02-151-1/+1
|
* Abstract over the way eventlogs are flushedalexbiehl2017-01-311-3/+18
| | | | | | | | | | | | | | | | | | | | Currently eventlog data is always written to a file `progname.eventlog`. This patch introduces the `flushEventLog` field in `RtsConfig` which allows to customize the writing of eventlog data. One possible scenario is the ongoing live-profile-monitor effort by @NCrashed which slurps all eventlog data through `fluchEventLog`. `flushEventLog` takes a buffer with eventlog data and its size and returns `false` (0) in case eventlog data could not be procesed. Reviewers: simonmar, austin, erikd, bgamari Reviewed By: simonmar, bgamari Subscribers: qnikst, thomie, NCrashed Differential Revision: https://phabricator.haskell.org/D2934
* Use C99's boolBen Gamari2016-11-291-1/+1
| | | | | | | | | | | | Test Plan: Validate on lots of platforms Reviewers: erikd, simonmar, austin Reviewed By: erikd, simonmar Subscribers: michalt, thomie Differential Revision: https://phabricator.haskell.org/D2699
* Remove the DEBUG_<blah> variables, use RtsFlags directlySimon Marlow2016-08-031-41/+0
|
* Only trace cap/capset events if we're tracing anything elseSimon Marlow2016-08-031-5/+14
| | | | | | | | | | | | | | | | Summary: I was getting annoyed by cap/capset messages when using +RTS -DS, which doesn't cause any other trace messages to be emitted. This makes it possible to add --with-rtsopts=-DS when running tests, and not have all the tests fail due to spurious trace messages. Test Plan: validate Reviewers: duncan, bgamari, ezyang, austin, erikd Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2438
* Log heap profiler samples to event logBen Gamari2016-07-161-0/+43
| | | | | | | | | | | | Test Plan: Try it Reviewers: hvr, simonmar, austin, erikd Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1722 GHC Trac Issues: #11094
* rts: Fix C compiler warnings on WindowsErik de Castro Lopo2016-05-111-6/+7
| | | | | | | | | | | | | | | | Summary: Specifcally we want the MinGW compiler to use ISO print format specfifiers. Test Plan: Validate on Linux, OS X and Windows Reviewers: Phyx, austin, bgamari, simonmar Reviewed By: bgamari, simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2192
* rts: Replace `nat` with `uint32_t`Erik de Castro Lopo2016-05-051-4/+4
| | | | | | | | | | | | The `nat` type was an alias for `unsigned int` with a comment saying it was at least 32 bits. We keep the typedef in case client code is using it but mark it as deprecated. Test Plan: Validated on Linux, OS X and Windows Reviewers: simonmar, austin, thomie, hvr, bgamari, hsyl20 Differential Revision: https://phabricator.haskell.org/D2166
* Remove cygwin32_HOST_OS #ifdefsErik de Castro Lopo2015-10-261-1/+1
| | | | | | | | | | | | | | | | | Build system support for Cygwin was removed in b6be81b841. Test Plan: - Validate on x86_64/linux - Cross-compile rts/RtsSymbols.c and rts/Linker.c to Windows using the i686-w64-mingw32-gcc and x86_64-w64-mingw32-gcc cross compilers. Reviewers: hvr, austin, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1371
* tracing: Kill EVENT_STARTUPBen Gamari2015-09-051-7/+0
| | | | | This has been unnecessary for quite some time due to the create/delete capability events.
* Squash typos in commentsGabor Greif2015-06-121-1/+1
|
* Don't truncate traceEvents to 512 bytes (#8309)Thomas Miedema2015-02-171-21/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Don't call postLogMsg to post a user msg, because it truncates messages to 512 bytes. Rename traceCap_stderr and trace_stderr to vtraceCap_stderr and trace_stderr, to signal that they take a va_list (similar to vdebugBelch vs debugBelch). See #3874 for the original reason behind traceFormatUserMsg. See the commit msg in #9395 (d360d440) for a discussion about using null-terminated strings vs strings with an explicit length. Test Plan: Run `cabal install ghc-events` and inspect the result of `ghc-events show` on an eventlog file created with `ghc -eventlog Test.hs` and `./Test +RTS -l`, where Test.hs contains: ``` import Debug.Trace main = traceEvent (replicate 510 'a' ++ "bcd") $ return () ``` Depends on D655. Reviewers: austin Reviewed By: austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D656 GHC Trac Issues: #8309
* Add missing va_end to va_startThomas Miedema2015-02-171-0/+2
| | | | | | | | | | | | Summary: See also ab9711d8. Reviewers: austin Reviewed By: austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D655
* Revert "rts: add Emacs 'Local Variables' to every .c file"Simon Marlow2014-09-291-8/+0
| | | | This reverts commit 39b5c1cbd8950755de400933cecca7b8deb4ffcd.
* rts: detabify/dewhitespace Trace.cAustin Seipp2014-08-201-20/+20
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* rts: add Emacs 'Local Variables' to every .c fileAustin Seipp2014-07-281-0/+8
| | | | | | | | This will hopefully help ensure some basic consistency in the forward by overriding buffer variables. In particular, it sets the wrap length, the offset to 4, and turns off tabs. Signed-off-by: Austin Seipp <austin@well-typed.com>
* Implement atomicReadMVar, fixing #4001.Edward Z. Yang2013-07-091-0/+1
| | | | | | | | | We add the invariant to the MVar blocked threads queue that threads blocked on an atomic read are always at the front of the queue. This invariant is easy to maintain, since takers are only ever added to the end of the queue. Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
* Fix build on OS X (fix from Duncan Coutts)Ian Lynagh2012-10-161-0/+5
|
* Add a new traceMarker# primop for use in profiling outputDuncan Coutts2012-10-151-0/+22
| | | | | | | | | In time-based profiling visualisations (e.g. heap profiles and ThreadScope) it would be useful to be able to mark particular points in the execution and have those points in time marked in the visualisation. The traceMarker# primop currently emits an event into the eventlog. In principle it could be extended to do something in the heap profiling too.
* More OS X build fixesIan Lynagh2012-09-141-13/+13
|
* Deprecate lnat, and use StgWord insteadSimon Marlow2012-09-071-23/+23
| | | | | | | | | | | | lnat was originally "long unsigned int" but we were using it when we wanted a 64-bit type on a 64-bit machine. This broke on Windows x64, where long == int == 32 bits. Using types of unspecified size is bad, but what we really wanted was a type with N bits on an N-bit machine. StgWord is exactly that. lnat was mentioned in some APIs that clients might be using (e.g. StackOverflowHook()), so we leave it defined but with a comment to say that it's deprecated.
* Define the task-tracking eventsDuncan Coutts2012-07-101-0/+46
| | | | | | | | | | | | | Based on initial patches by Mikolaj Konarski <mikolaj@well-typed.com> These new eventlog events are to let profiling tools keep track of all the OS threads that belong to an RTS capability at any moment in time. In the RTS, OS threads correspond to the Task abstraction, so that is what we track. There are events for tasks being created, migrated between capabilities and deleted. In particular the task creation event also records the kernel thread id which lets us match up the OS thread with data collected by others tools (in the initial use case with Linux's perf tool, but in principle also with DTrace).
* Fix warnings on Win64Ian Lynagh2012-04-261-13/+13
| | | | | | Mostly this meant getting pointer<->int conversions to use the right sizes. lnat is now size_t, rather than unsigned long, as that seems a better match for how it's used.
* Turn on TRACE_gc with +RTS -Ds (this regressed at some point)Simon Marlow2012-04-111-1/+2
|
* Fix crash with debug tracing and the new heap eventsSimon Marlow2012-04-111-10/+28
|
* Add the GC_GLOBAL_SYNC event marking that all caps are stopped for GCMikolaj2012-04-041-0/+3
| | | | | | | | | Quoting design rationale by dcoutts: The event indicates that we're doing a stop-the-world GC and all other HECs should be between their GC_START and GC_END events at that moment. We don't want to use GC_STATS_GHC for that, because GC_STATS_GHC is for extra GHC-specific info, not something we have to rely on to be able to match the GC pauses across HECs to a particular global GC.
* Fix the timestamps in GC_START and GC_END events on the GC-initiating capMikolaj2012-04-041-0/+13
| | | | | | | | | | | There was a discrepancy between GC times reported in +RTS -s and the timestamps of GC_START and GC_END events on the cap, on which +RTS -s stats for the given GC are based. This is fixed by posting the events with exactly the same timestamp as generated for the stat calculation. The calls posting the events are moved too, so that the events are emitted close to the time instant they claim to be emitted at. The GC_STATS_GHC was moved, too, ensuring it's emitted before the moved GC_END on all caps, which simplifies tools code.
* Add new eventlog events for various heap and GC statisticsDuncan Coutts2012-04-041-0/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | They cover much the same info as is available via the GHC.Stats module or via the '+RTS -s' textual output, but via the eventlog and with a better sampling frequency. We have three new generic heap info events and two very GHC-specific ones. (The hope is the general ones are usable by other implementations that use the same eventlog system, or indeed not so sensitive to changes in GHC itself.) The general ones are: * total heap mem allocated since prog start, on a per-HEC basis * current size of the heap (MBlocks reserved from OS for the heap) * current size of live data in the heap Currently these are all emitted by GHC at GC time (live data only at major GC). The GHC specific ones are: * an event giving various static heap paramaters: * number of generations (usually 2) * max size if any * nursary size * MBlock and block sizes * a event emitted on each GC containing: * GC generation (usually just 0,1) * total bytes copied * bytes lost to heap slop and fragmentation * the number of threads in the parallel GC (1 for serial) * the maximum number of bytes copied by any par GC thread * the total number of bytes copied by all par GC threads (these last three can be used to calculate an estimate of the work balance in parallel GCs)
* Add eventlog/trace stuff for capabilities: create/delete/enable/disableDuncan Coutts2012-04-041-6/+35
| | | | | | | | | | | | | | | | | | | | | | | Now that we can adjust the number of capabilities on the fly, we need this reflected in the eventlog. Previously the eventlog had a single startup event that declared a static number of capabilities. Obviously that's no good anymore. For compatability we're keeping the EVENT_STARTUP but adding new EVENT_CAP_CREATE/DELETE. The EVENT_CAP_DELETE is actually just the old EVENT_SHUTDOWN but renamed and extended (using the existing mechanism to extend eventlog events in a compatible way). So we now emit both EVENT_STARTUP and EVENT_CAP_CREATE. One day we will drop EVENT_STARTUP. Since reducing the number of capabilities at runtime does not really delete them, it just disables them, then we also have new events for disable/enable. The old EVENT_SHUTDOWN was in the scheduler class of events. The new EVENT_CAP_* events are in the unconditional class, along with the EVENT_CAPSET_* ones. Knowing when capabilities are created and deleted is crucial to making sense of eventlogs, you always want those events. In any case, they're extremely low volume.
* when tracing to stderr, make the capset events conditional on TRACE_schedSimon Marlow2012-03-231-3/+4
|
* Disable some debug prints that a plain +RTS -DS was enablingIan Lynagh2012-03-221-0/+2
|
* Allow the number of capabilities to be increased at runtime (#3729)Simon Marlow2011-12-061-0/+7
| | | | | At present the number of capabilities can only be *increased*, not decreased. The latter presents a few more challenges!
* Add eventlog event for thread labelsDuncan Coutts2011-11-041-0/+18
| | | | | | The existing GHC.Conc.labelThread will now also emit the the thread label into the eventlog. Profiling tools like ThreadScope could then use the thread labels rather than thread numbers.
* Add an RTS eventlog tracing class for user messagesDuncan Coutts2011-10-271-3/+11
| | | | Enables people to turn them on/off. Defaults to on.
* Add new eventlog EVENT_WALL_CLOCK_TIME for time matchingDuncan Coutts2011-10-261-0/+6
| | | | | | | | | | | | | | Eventlog timestamps are elapsed times (in nanoseconds) relative to the process start. To be able to merge eventlogs from multiple processes we need to be able to align their timelines. If they share a clock domain (or a user judges that their clocks are sufficiently closely synchronised) then it is sufficient to know how the eventlog timestamps match up with the clock. The EVENT_WALL_CLOCK_TIME contains the clock time with (up to) nanosecond precision. It is otherwise an ordinary event and so contains the usual timestamp for the same moment in time. It therefore enables us to match up all the eventlog timestamps with clock time.
* Rename traceCapsetModify for consistency and clarityDuncan Coutts2011-10-261-13/+13
|
* Add new fully-accurate per-spark trace/eventlog eventsDuncan Coutts2011-07-181-16/+70
| | | | | | | | | | | | | | Replaces the existing EVENT_RUN/STEAL_SPARK events with 7 new events covering all stages of the spark lifcycle: create, dud, overflow, run, steal, fizzle, gc The sampled spark events are still available. There are now two event classes for sparks, the sampled and the fully accurate. They can be enabled/disabled independently. By default +RTS -l includes the sampled but not full detail spark events. Use +RTS -lf-p to enable the detailed 'f' and disable the sampled 'p' spark. Includes work by Mikolaj <mikolaj.konarski@gmail.com>
* Move GC tracing into a separate trace classDuncan Coutts2011-07-181-34/+56
| | | | | | | Previously GC was included in the scheduler trace class. It can be enabled specifically with +RTS -vg or -lg, though note that both -v and -l on their own now default to a sensible set of trace classes, currently: scheduler, gc and sparks.
* add a new trace class for spark eventsDuncan Coutts2011-07-181-0/+10
|
* Add spark counter tracingDuncan Coutts2011-07-181-0/+16
| | | | | | | A new eventlog event containing 7 spark counters/statistics: sparks created, dud, overflowed, converted, GC'd, fizzled and remaining. These are maintained and logged separately for each capability. We log them at startup, on each GC (minor and major) and on shutdown.
* Fix a warning in DEBUG codeIan Lynagh2011-06-011-1/+1
|
* fix format specs on 64-bit buildsSimon Marlow2011-05-311-4/+6
|
* Emit various bits of OS process info into the eventlogDuncan Coutts2011-05-261-0/+49
| | | | | The process ID, parent process ID, rts name and version The program arguments and environment.