summaryrefslogtreecommitdiff
path: root/rts/posix
Commit message (Collapse)AuthorAgeFilesLines
* Drop the per-task timing stats, give a summary only (#5897)Simon Marlow2012-03-021-1/+0
| | | | | | | | | | | | | | | | | | | | | | We were keeping around the Task struct (216 bytes) for every worker we ever created, even though we only keep a maximum of 6 workers per Capability. These Task structs accumulate and cause a space leak in programs that do lots of safe FFI calls; this patch frees the Task struct as soon as a worker exits. One reason we were keeping the Task structs around is because we print out per-Task timing stats in +RTS -s, but that isn't terribly useful. What is sometimes useful is knowing how *many* Tasks there were. So now I'm printing a single-line summary, this is for the program in TASKS: 2001 (1 bound, 31 peak workers (2000 total), using -N1) So although we created 2k tasks overall, there were only 31 workers active at any one time (which is exactly what we expect: the program makes 30 safe FFI calls concurrently). This also gives an indication of how many capabilities were being used, which is handy if you use +RTS -N without an explicit number.
* (some) tabs -> spacesGabor Greif2012-02-271-1/+1
|
* Fix bug introduced in fac8ecbbafde17dd92439c41747223c43e9d2b80Simon Marlow2012-01-191-6/+6
| | | | Fixes recent failures in hGetBuf001.
* Fix bug causing polling instead of blocking in the non-threaded RTS (#5773)Simon Marlow2012-01-161-18/+17
| | | | | | | | | This was a regression introduced accidentally in 6b1098511aaabd2c9503ee7be6da1944466f9cb4. We were previously passing a large time value to select() to simulate blocking, and this broke due to a change from unsigned to signed arithmetic. I've refactored it to be less fragile now - we just pass NULL as the timeval parameter to select(), which is the correct way to do blocking.
* Fix for tick intervals greater than one second.Simon Marlow2012-01-161-2/+2
|
* In the SIGTSTP handler, throw SIGSTOP instead of re-throwing SIGTSTPSimon Marlow2012-01-031-14/+14
|
* add a missing error checkSimon Marlow2011-12-131-0/+3
|
* Add a mutex around stg_sig_installSimon Marlow2011-12-121-19/+42
| | | | | | Protects against a race when two threads call installHandler simultaneously. This was causing occasional failure of the test libraries/process/tests/3231(threaded2).
* remove duplicate getStablePtr (already done in hs_init())Simon Marlow2011-12-121-4/+0
|
* change a contextSwitchCapability() to interruptCapability()Simon Marlow2011-12-121-1/+1
|
* Define getNumberOfProcessors() even when !THREADED_RTSSimon Marlow2011-12-071-1/+6
|
* Make forkProcess work with +RTS -NSimon Marlow2011-12-063-7/+6
| | | | | | | | | | | | | | | | | | | | | | Consider this experimental for the time being. There are a lot of things that could go wrong, but I've verified that at least it works on the test cases we have. I also did some API cleanups while I was here. Previously we had: Capability * rts_eval (Capability *cap, HaskellObj p, /*out*/HaskellObj *ret); but this API is particularly error-prone: if you forget to discard the Capability * you passed in and use the return value instead, then you're in for subtle bugs with +RTS -N later on. So I changed all these functions to this form: void rts_eval (/* inout */ Capability **cap, /* in */ HaskellObj p, /* out */ HaskellObj *ret) It's much harder to use this version incorrectly, because you have to pass the Capability in by reference.
* Time handling overhaulSimon Marlow2011-11-255-118/+93
| | | | | | | | | | | | | | | | | | | | | Terminology cleanup: the type "Ticks" has been renamed "Time", which is an StgWord64 in units of TIME_RESOLUTION (currently nanoseconds). The terminology "tick" is now used consistently to mean the interval between timer signals. The ticker now always ticks in realtime (actually CLOCK_MONOTONIC if we have it). Before it used CPU time in the non-threaded RTS and realtime in the threaded RTS, but I've discovered that the CPU timer has terrible resolution (at least on Linux) and isn't much use for profiling. So now we always use realtime. This should also fix The default tick interval is now 10ms, except when profiling where we drop it to 1ms. This gives more accurate profiles without affecting runtime too much (<1%). Lots of cleanups - the resolution of Time is now in one place only (Rts.h) rather than having calculations that depend on the resolution scattered all over the RTS. I hope I found them all.
* Add rts time util getUnixEpochTimeDuncan Coutts2011-10-261-0/+16
| | | | | | The other existing time utilities give us time elapsed since process or thread start. This is for wall clock time, using the common Unix epoch interpretation.
* Remove some antiquated C constructsIan Lynagh2011-08-011-3/+3
| | | | | | | | Fixes validate on amd64/Linux with: SRC_CC_OPTS += -Wmissing-parameter-type SRC_CC_OPTS += -Wold-style-declaration SRC_CC_OPTS += -Wold-style-definition
* SafeHaskell: Fix compilation errors.David Terei2011-06-171-1/+1
|
* SafeHaskell: Even more fixing to work with safe baseDavid Terei2011-06-171-1/+1
|
* Emit various bits of OS process info into the eventlogDuncan Coutts2011-05-261-0/+44
| | | | | The process ID, parent process ID, rts name and version The program arguments and environment.
* Rename System.Event to GHC.EventIan Lynagh2011-03-211-2/+2
| | | | It's just an internal GHC library, for now at least
* Include kfreebsdgnu in the list of Target Platforms.Marco Silva2011-01-181-1/+1
|
* catch SIGTSTP and save/restore terminal settings (#4460)Simon Marlow2011-01-071-0/+77
| | | | | | | | | As far as I can tell, it is the responsibility of the program to save and restore its own terminal settings across a suspend/foreground, the shell doesn't do it (which seems odd). So I've added a signal handler for SIGTSTP to the RTS which will save and restore the terminal settings iff we modified them with hSetBuffering or hSetEcho (we already restore them at exit time in these cases).
* Implement stack chunks and separate TSO/STACK objectsSimon Marlow2010-12-151-9/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch makes two changes to the way stacks are managed: 1. The stack is now stored in a separate object from the TSO. This means that it is easier to replace the stack object for a thread when the stack overflows or underflows; we don't have to leave behind the old TSO as an indirection any more. Consequently, we can remove ThreadRelocated and deRefTSO(), which were a pain. This is obviously the right thing, but the last time I tried to do it it made performance worse. This time I seem to have cracked it. 2. Stacks are now represented as a chain of chunks, rather than a single monolithic object. The big advantage here is that individual chunks are marked clean or dirty according to whether they contain pointers to the young generation, and the GC can avoid traversing clean stack chunks during a young-generation collection. This means that programs with deep stacks will see a big saving in GC overhead when using the default GC settings. A secondary advantage is that there is much less copying involved as the stack grows. Programs that quickly grow a deep stack will see big improvements. In some ways the implementation is simpler, as nothing special needs to be done to reclaim stack as the stack shrinks (the GC just recovers the dead stack chunks). On the other hand, we have to manage stack underflow between chunks, so there's a new stack frame (UNDERFLOW_FRAME), and we now have separate TSO and STACK objects. The total amount of code is probably about the same as before. There are new RTS flags: -ki<size> Sets the initial thread stack size (default 1k) Egs: -ki4k -ki2m -kc<size> Sets the stack chunk size (default 32k) -kb<size> Sets the stack chunk buffer size (default 1k) -ki was previously called just -k, and the old name is still accepted for backwards compatibility. These new options are documented.
* Export the value of the signal used by scheduler (#4504)Dmitry Astapov2010-12-081-0/+6
|
* Remove references to Haskell 98Ian Lynagh2010-11-232-2/+2
| | | | | They are no longer right, as we have Haskell' generating new Haskell standards.
* On Windows, when returning memory to the OS, we try to release itIan Lynagh2010-11-011-0/+4
| | | | as well as decommiting it.
* Interruptible FFI calls with pthread_kill and CancelSynchronousIO. v4Edward Z. Yang2010-09-191-0/+10
| | | | | | | | | | | | | | | | | | | | | | | This is patch that adds support for interruptible FFI calls in the form of a new foreign import keyword 'interruptible', which can be used instead of 'safe' or 'unsafe'. Interruptible FFI calls act like safe FFI calls, except that the worker thread they run on may be interrupted. Internally, it replaces BlockedOnCCall_NoUnblockEx with BlockedOnCCall_Interruptible, and changes the behavior of the RTS to not modify the TSO_ flags on the event of an FFI call from a thread that was interruptible. It also modifies the bytecode format for foreign call, adding an extra Word16 to indicate interruptibility. The semantics of interruption vary from platform to platform, but the intent is that any blocking system calls are aborted with an error code. This is most useful for making function calls to system library functions that support interrupting. There is no support for pre-Vista Windows. There is a partner testsuite patch which adds several tests for this functionality.
* give a better error message in the non-threaded RTS for out-of-range FDsSimon Marlow2010-09-291-2/+10
| | | | | | # ./aw aw: file descriptor 1027 out of range for select (0--1024). Recompile with -threaded to work around this.
* Use an empty signal handler for SIGPIPE instead of SIG_IGNSimon Marlow2010-09-251-1/+12
| | | | | This is so that the SIGPIPE handler gets reset to the default automatically on exec().
* Fix getThreadCPUTime()Simon Marlow2010-09-131-10/+19
| | | | | | ever since the patch "Check with sysconf _POSIX_THREAD_CPUTIME", it has been returning incorrect results, because the sysconf variable to check should have been _SC_THREAD_CPUTIME, not _POSIX_THREAD_CPUTIME.
* Use clock_gettime (if available) to measure the process CPU timeSimon Marlow2010-09-131-4/+26
| | | | | This is much more accurate than getrusage, which was giving misleading results when trying to time very quick operations like a minor GC.
* Return memory to the OS; trac #698Ian Lynagh2010-08-131-24/+10
|
* Integrate new I/O manager, with signal supportJohan Tibell2010-07-241-27/+34
|
* Test for (fd < 0) before trying to FD_SET itIan Lynagh2010-08-041-2/+2
|
* Add thread affinity support for FreeBSDGabor Pali2010-07-201-2/+31
| | | | | | | | | - Implement missing functions for setting thread affinity and getting real number of processors. - It is available starting from 7.1-RELEASE, which includes a native support for managing CPU sets. - Add __BSD_VISIBLE, since it is required for certain types to be visible in addition to POSIX & C99.
* Fix the symbol visibility pragmasSimon Marlow2010-06-171-2/+2
|
* undo debugging codeSimon Marlow2010-04-061-3/+2
|
* New implementation of BLACKHOLEsSimon Marlow2010-03-291-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Cast to (void*) to stifle warning about signednessbenl@cse.unsw.edu.au2010-02-031-2/+2
|
* Don't Terminate the ticker thread (#3748)Simon Marlow2010-01-271-1/+1
|
* Fix signal segfaults on Solaris (#3790)Simon Marlow2010-01-261-1/+8
|
* Partial support for Haiku (#3727)Simon Marlow2009-12-211-1/+1
|
* #include <sys/select.h> if we have it (#3760)Simon Marlow2009-12-161-0/+4
|
* The rest of the #1185 patch (forkProcess and -threaded)Simon Marlow2009-11-132-1/+9
| | | | | Due to darcs confusion, I managed to leave out part of the patch for #1185. This should make 1185(threaded1) go through now.
* Second attempt to fix #1185 (forkProcess and -threaded)Simon Marlow2009-11-111-4/+15
| | | | | | | | | | | | Patch 1/2: second part of the patch is to libraries/base This time without dynamic linker hacks, instead I've expanded the existing rts/Globals.c to cache more CAFs, specifically those in GHC.Conc. We were already using this trick for signal handlers, I should have realised before. It's still quite unsavoury, but we can do away with rts/Globals.c in the future when we switch to a dynamically-linked GHCi.
* Rollback #1185 fixSimon Marlow2009-11-062-9/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As far as I can tell, the hack I was using in rts/Linker.c won't work on OS X. Back to the drawing board. rolling back: Tue Nov 3 16:05:47 GMT 2009 Simon Marlow <marlowsd@gmail.com> * Fix #1185 (RTS part, also needs corresponding change to libraries/base) GHC.Conc.ensureIOManagerIsRunning now creates an IO manager thread if one does not exist or has died/exited. Unfortunately this exposed a problem caused by the fact that we have two base packages, and hence two IO managers, in GHCi: see NOTE [io-manager-ghci] in rts/Linker.c. The workaround can go away if/when we switch to a dynamically linked GHCi. M ./rts/Linker.c -6 +47 M ./rts/Schedule.c +4 M ./rts/package.conf.in +16 M ./rts/posix/Signals.c -1 +7 M ./rts/posix/Signals.h +2 Wed Nov 4 10:11:03 GMT 2009 Simon Marlow <marlowsd@gmail.com> * hopefully fix validate breakage on OS X and Windows M ./rts/Linker.c -1 +1 Wed Nov 4 16:27:40 GMT 2009 Simon Marlow <marlowsd@gmail.com> * fix build failure on Windows M ./rts/Linker.c -1 +1
* Fix #1185 (RTS part, also needs corresponding change to libraries/base)Simon Marlow2009-11-032-1/+9
| | | | | | | | | | | GHC.Conc.ensureIOManagerIsRunning now creates an IO manager thread if one does not exist or has died/exited. Unfortunately this exposed a problem caused by the fact that we have two base packages, and hence two IO managers, in GHCi: see NOTE [io-manager-ghci] in rts/Linker.c. The workaround can go away if/when we switch to a dynamically linked GHCi.
* FIX #711 implement osFreeAllMBlocks for unixAustin Seipp2009-09-101-3/+28
|
* Omit visibility pragmas on Windows (fixes warnings/validate failures)Simon Marlow2009-09-091-2/+2
|
* Declare RTS-private prototypes with __attribute__((visibility("hidden")))Simon Marlow2009-08-054-6/+9
| | | | | | | | | | This has no effect with static libraries, but when the RTS is in a shared library it does two things: - it prevents the function from being exposed by the shared library - internal calls to the function can use the faster non-PLT calls, because the function cannot be overriden at link time.
* add #include <sys/types.h> (hopefully fixes OS X build)Simon Marlow2009-08-061-1/+2
|