summaryrefslogtreecommitdiff
path: root/rts/Timer.c
Commit message (Collapse)AuthorAgeFilesLines
* Prefer #if defined to #ifdefBen Gamari2017-04-281-2/+2
| | | | Our new CPP linter enforces this.
* 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
* rts/Timer: Actually fix #9105Ben Gamari2016-01-271-1/+3
| | | | | | | | | | | | | | | | | | | jberthold astutely pointed out that the previous fix (D1822) could not have possibly fixed the issue as the patch would only have had any effect if !PROFILING. Test Plan: Check for reduced CPU usage when compiled with `-prof` but without `+RTS -p` Reviewers: simonmar, austin, jberthold Reviewed By: simonmar, jberthold Subscribers: simonmar, thomie Differential Revision: https://phabricator.haskell.org/D1844 GHC Trac Issues: #9105
* rts: Disable tick timer unless really neededBen Gamari2016-01-221-3/+8
| | | | | | | | | | | | | | | | | | | | | | Trac #9105 notes significant CPU usage by an otherwise idle process when compiled with profiling. The reason for this is that we keep the tick timer active in the profiling RTS even if profiling wasn't requested at runtime. If the user requests any sort of profiling then we need to keep the timer active to ensure that samples are collected. Test Plan: Validate, check CPU usage, ensure profiling still works Reviewers: simonmar, austin Reviewed By: simonmar, austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1822 GHC Trac Issues: #9105
* Revert "rts: add Emacs 'Local Variables' to every .c file"Simon Marlow2014-09-291-8/+0
| | | | This reverts commit 39b5c1cbd8950755de400933cecca7b8deb4ffcd.
* rts: detabify/dewhitespace Timer.cAustin Seipp2014-08-201-3/+3
| | | | 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>
* Eliminate atomic_inc_by and instead medofiy atomic_inc.Ryan Newton2013-08-211-1/+1
|
* Another overhaul of the recent_activity / idle GC handling (#5991)Simon Marlow2012-09-241-14/+15
| | | | | | | | | | | | | | | Improvements: - we now turn off the timer signal in the non-threaded RTS after idleGCDelay. This should make the xmonad users on #5991 happy. - we now turn off the timer signal after idleGCDelay even if the idle GC is disabled with +RTS -I0. - we now do *not* turn off the timer when profiling. - more comments to explain the meaning of the various ACTIVITY_* values
* Fix a scheduling bug in the threaded RTSSimon Marlow2011-12-011-1/+1
| | | | | | | | | | | | | | | The parallel GC was using setContextSwitches() to stop all the other threads, which sets the context_switch flag on every Capability. That had the side effect of causing every Capability to also switch threads, and since GCs can be much more frequent than context switches, this increased the context switch frequency. When context switches are expensive (because the switch is between two bound threads or a bound and unbound thread), the difference is quite noticeable. The fix is to have a separate flag to indicate that a Capability should stop and return to the scheduler, but not switch threads. I've called this the "interrupt" flag.
* Fix #4074 (I hope).Simon Marlow2010-05-181-4/+18
| | | | | | | 1. allow multiple threads to call startTimer()/stopTimer() pairs 2. disable the timer around fork() in forkProcess() A corresponding change to the process package is required.
* New implementation of BLACKHOLEsSimon Marlow2010-03-291-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This replaces the global blackhole_queue with a clever scheme that enables us to queue up blocked threads on the closure that they are blocked on, while still avoiding atomic instructions in the common case. Advantages: - gets rid of a locked global data structure and some tricky GC code (replacing it with some per-thread data structures and different tricky GC code :) - wakeups are more prompt: parallel/concurrent performance should benefit. I haven't seen anything dramatic in the parallel benchmarks so far, but a couple of threading benchmarks do improve a bit. - waking up a thread blocked on a blackhole is now O(1) (e.g. if it is the target of throwTo). - less sharing and better separation of Capabilities: communication is done with messages, the data structures are strictly owned by a Capability and cannot be modified except by sending messages. - this change will utlimately enable us to do more intelligent scheduling when threads block on each other. This is what started off the whole thing, but it isn't done yet (#3838). I'll be documenting all this on the wiki in due course.
* Don't Terminate the ticker thread (#3748)Simon Marlow2010-01-271-2/+2
|
* RTS tidyup sweep, first phaseSimon Marlow2009-08-021-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The first phase of this tidyup is focussed on the header files, and in particular making sure we are exposinng publicly exactly what we need to, and no more. - Rts.h now includes everything that the RTS exposes publicly, rather than a random subset of it. - Most of the public header files have moved into subdirectories, and many of them have been renamed. But clients should not need to include any of the other headers directly, just #include the main public headers: Rts.h, HsFFI.h, RtsAPI.h. - All the headers needed for via-C compilation have moved into the stg subdirectory, which is self-contained. Most of the headers for the rest of the RTS APIs have moved into the rts subdirectory. - I left MachDeps.h where it is, because it is so widely used in Haskell code. - I left a deprecated stub for RtsFlags.h in place. The flag structures are now exposed by Rts.h. - Various internal APIs are no longer exposed by public header files. - Various bits of dead code and declarations have been removed - More gcc warnings are turned on, and the RTS code is more warning-clean. - More source files #include "PosixSource.h", and hence only use standard POSIX (1003.1c-1995) interfaces. There is a lot more tidying up still to do, this is just the first pass. I also intend to standardise the names for external RTS APIs (e.g use the rts_ prefix consistently), and declare the internal APIs as hidden for shared libraries.
* Move the context_switch flag into the CapabilitySimon Marlow2008-09-191-1/+1
| | | | | Fixes a long-standing bug that could in some cases cause sub-optimal scheduling behaviour.
* FIX #1623: disable the timer signal when the system is idle (threaded RTS only)Simon Marlow2007-09-031-15/+37
| | | | | | | | | | Having a timer signal go off regularly is bad for power consumption, and generally bad practice anyway (it means the app cannot be completely swapped out, for example). Fortunately the threaded RTS already had a way to detect when the system was idle, so that it can trigger a GC and thereby find deadlocks. After performing the GC, we now turn off timer signals, and re-enable them again just before running any Haskell code.
* Fix the +RTS -V0 option introduced recently; it didn't work at all, now it does.Simon Marlow2007-07-081-1/+3
| | | | | Also, I documented it. +RTS -V0 disables the internal RTS timer completely, which is useful for repeatable debugginng.
* +RTS -V0 disables the interval timer completely (for repeatable debugging)Simon Marlow2007-06-271-1/+3
|
* Basic heap profile support without -profSimon Marlow2007-04-271-5/+0
| | | | | | | | | | | | | | Now that constructor info tables contain the name of the constructor, we can generate useful heap profiles without requiring the whole program and libraries to be compiled with -prof. So now, "+RTS -hT" generates a heap profile for any program, dividing the profile by constructor. It wouldn't be hard to add support for grouping constructors by module, or to restrict the profile to certain constructors/modules/packages. This means that for the first time we can get heap profiles for GHCi, which was previously impossible because the byte-code interpreter and linker don't work with -prof.
* Use timer_create() for the interval timer, if availableSimon Marlow2007-03-021-4/+4
| | | | | | | | | | | This lets the threaded RTS use SIGVTALRM rather than SIGALRM for its interval timer signal, so the threaded and non-threaded RTS are compatible. It unfortunately doesn't completely fix #850/#1156, for that we really have to use a restartable sleep instead of usleep(). Also I cleaned up the timer API a little: instead of returning an error value that ultimately gets ignored, we now report errors from system calls and exit.
* Split GC.c, and move storage manager into sm/ directorySimon Marlow2006-10-241-0/+1
| | | | | | | | | | | | | | | | | In preparation for parallel GC, split up the monolithic GC.c file into smaller parts. Also in this patch (and difficult to separate, unfortunatley): - Don't include Stable.h in Rts.h, instead just include it where necessary. - consistently use STATIC_INLINE in source files, and INLINE_HEADER in header files. STATIC_INLINE is now turned off when DEBUG is on, to make debugging easier. - The GC no longer takes the get_roots function as an argument. We weren't making use of this generalisation.
* new RTS flag: -V to modify the resolution of the RTS timerIan Lynagh2006-09-051-6/+8
| | | | | | | | | Fixed version of an old patch by Simon Marlow. His description read: Also, now an arbitrarily short context switch interval may now be specified, as we increase the RTS ticker's resolution to match the requested context switch interval. This also applies to +RTS -i (heap profiling) and +RTS -I (the idle GC timer). +RTS -V is actually only required for increasing the resolution of the profile timer.
* call wakeUpRts() in the correct placeSimon Marlow2006-06-141-2/+1
|
* fix possible ^C problemsSimon Marlow2006-06-081-13/+1
| | | | | | | Calling prodAllCapabilities() from interruptStgRts() was wrong, for the same reasons that we stopped doing it in handle_tick(). We now use the same mechanism (send a byte down the pipe to the IO manager thread), but abstract it in a wakeUpRts() function in the scheduler.
* Better control of the IO manager thread; improvements to deadlock checkingSimon Marlow2006-05-241-0/+8
| | | | | | | | | | | | | | | | | In the threaded RTS on *nix platforms: - we now start the IO manager thread eagerly at startup time (previously was started on demand). - we now ask the IO manager thread to stop at shutdown - In Timer.c:handle_tick, if it looks like we might be in a deadlock, instead of calling prodOneCapability() which was known to be wrong, we now send a byte down the IO manager's pipe to wake it up. This also avoids a case of double-acquisition of a mutex, which happened if prodOneCapability() was called while the current thread was holding a mutex.
* Reorganisation of the source treeSimon Marlow2006-04-071-0/+102
Most of the other users of the fptools build system have migrated to Cabal, and with the move to darcs we can now flatten the source tree without losing history, so here goes. The main change is that the ghc/ subdir is gone, and most of what it contained is now at the top level. The build system now makes no pretense at being multi-project, it is just the GHC build system. No doubt this will break many things, and there will be a period of instability while we fix the dependencies. A straightforward build should work, but I haven't yet fixed binary/source distributions. Changes to the Building Guide will follow, too.