1. 05 Sep, 2006 1 commit
    • Ian Lynagh's avatar
      new RTS flag: -V to modify the resolution of the RTS timer · 93db1991
      Ian Lynagh authored
      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.
      93db1991
  2. 07 Apr, 2006 1 commit
    • Simon Marlow's avatar
      Reorganisation of the source tree · 0065d5ab
      Simon Marlow authored
      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.
      0065d5ab
  3. 06 Apr, 2006 1 commit
  4. 21 Oct, 2005 1 commit
    • simonmar's avatar
      [project @ 2005-10-21 14:02:17 by simonmar] · 03a9ff01
      simonmar authored
      Big re-hash of the threaded/SMP runtime
      
      This is a significant reworking of the threaded and SMP parts of
      the runtime.  There are two overall goals here:
      
        - To push down the scheduler lock, reducing contention and allowing
          more parts of the system to run without locks.  In particular,
          the scheduler does not require a lock any more in the common case.
      
        - To improve affinity, so that running Haskell threads stick to the
          same OS threads as much as possible.
      
      At this point we have the basic structure working, but there are some
      pieces missing.  I believe it's reasonably stable - the important
      parts of the testsuite pass in all the (normal,threaded,SMP) ways.
      
      In more detail:
      
        - Each capability now has a run queue, instead of one global run
          queue.  The Capability and Task APIs have been completely
          rewritten; see Capability.h and Task.h for the details.
      
        - Each capability has its own pool of worker Tasks.  Hence, Haskell
          threads on a Capability's run queue will run on the same worker
          Task(s).  As long as the OS is doing something reasonable, this
          should mean they usually stick to the same CPU.  Another way to
          look at this is that we're assuming each Capability is associated
          with a fixed CPU.
      
        - What used to be StgMainThread is now part of the Task structure.
          Every OS thread in the runtime has an associated Task, and it
          can ask for its current Task at any time with myTask().
      
        - removed RTS_SUPPORTS_THREADS symbol, use THREADED_RTS instead
          (it is now defined for SMP too).
      
        - The RtsAPI has had to change; we must explicitly pass a Capability
          around now.  The previous interface assumed some global state.
          SchedAPI has also changed a lot.
      
        - The OSThreads API now supports thread-local storage, used to
          implement myTask(), although it could be done more efficiently
          using gcc's __thread extension when available.
      
        - I've moved some POSIX-specific stuff into the posix subdirectory,
          moving in the direction of separating out platform-specific
          implementations.
      
        - lots of lock-debugging and assertions in the runtime.  In particular,
          when DEBUG is on, we catch multiple ACQUIRE_LOCK()s, and there is
          also an ASSERT_LOCK_HELD() call.
      
      What's missing so far:
      
        - I have almost certainly broken the Win32 build, will fix soon.
      
        - any kind of thread migration or load balancing.  This is high up
          the agenda, though.
      
        - various performance tweaks to do
      
        - throwTo and forkProcess still do not work in SMP mode
      03a9ff01
  5. 31 Mar, 2005 1 commit
  6. 10 Nov, 2004 1 commit
  7. 12 Sep, 2004 1 commit
  8. 03 Sep, 2004 1 commit
    • simonmar's avatar
      [project @ 2004-09-03 15:28:18 by simonmar] · 95ca6bff
      simonmar authored
      Cleanup: all (well, most) messages from the RTS now go through the
      functions in RtsUtils: barf(), debugBelch() and errorBelch().  The
      latter two were previously called belch() and prog_belch()
      respectively.  See the comments for the right usage of these message
      functions.
      
      One reason for doing this is so that we can avoid spurious uses of
      stdout/stderr by Haskell apps on platforms where we shouldn't be using
      them (eg. non-console apps on Windows).
      95ca6bff
  9. 22 Dec, 2003 1 commit
    • simonmar's avatar
      [project @ 2003-12-22 16:27:10 by simonmar] · 354a661d
      simonmar authored
      Fix threaded RTS problem that is currently causing the conc007 test to
      loop indefinitely.  Comment from the source regarding this change:
      
      /* Major bogosity:
       *
       * In the threaded RTS, we can't set the virtual timer because the
       * thread which has the virtual timer might be sitting waiting for a
       * capability, and the virtual timer only ticks in CPU time.
       *
       * So, possible solutions:
       *
       * (1) tick in realtime.  Not very good, because this ticker is used for
       *     profiling, and this will give us unreliable time profiling
       *     results.  Furthermore, this requires picking a single OS thread
       *     to be the timekeeper, which is a bad idea because the thread in
       *     question might just be making a temporary call into Haskell land.
       *
       * (2) save/restore the virtual timer around excursions into STG land.
       *     Sounds great, but I tried it and the resolution of the virtual timer
       *     isn't good enough (on Linux) - most of our excursions fall
       *     within the timer's resolution and we never make any progress.
       *
       * (3) have a virtual timer in every OS thread.  Might be reasonable,
       *     because most of the time there is only ever one of these
       *     threads running, so it approximates a single virtual timer.
       *     But still quite bogus (and I got crashes when I tried this).
       *
       * For now, we're using (1), but this needs a better solution. --SDM
       */
      354a661d
  10. 29 Mar, 2003 2 commits
  11. 28 Mar, 2003 1 commit
  12. 22 Feb, 2003 1 commit
    • sof's avatar
      [project @ 2003-02-22 04:51:50 by sof] · 557947d3
      sof authored
      Clean up code&interfaces that deals with timers and asynchrony:
      
      - Timer.{c,h} now defines the platform-independent interface
        to the timing services needed by the RTS. Itimer.{c,h} +
        win32/Ticker.{c,h} defines the OS-specific services that
        creates/destroys a timer.
      - For win32 plats, drop the long-standing use of the 'multimedia'
        API timers and implement the ticking service ourselves. Simpler
        and more flexible.
      - Select.c is now solely for platforms that use select() to handle
        non-blocking I/O & thread delays. win32/AwaitEvent.c provides
        the same API on the Win32 side.
      - support threadDelay on win32 platforms via worker threads.
      
      Not yet compiled up on non-win32 platforms; will do once checked in.
      557947d3
  13. 16 Aug, 2002 1 commit
  14. 17 Jul, 2002 1 commit
    • simonmar's avatar
      [project @ 2002-07-17 09:21:48 by simonmar] · 7457757f
      simonmar authored
      Remove most #includes of system headers from Stg.h, and instead
      #include any required headers directly in each RTS source file.
      
      The idea is to (a) reduce namespace pollution from system headers that
      we don't need, (c) be clearer about dependencies on system things in
      the RTS, and (c) improve via-C compilation times (maybe).
      
      In practice though, HsBase.h #includes everything anyway, so the
      difference from the point of view of .hc source is minimal.  However,
      this makes it easier to move to zero-includes if we wanted to (see
      discussion on the FFI list; I'm still not sure that's possible but
      at least this is a step in the right direction).
      7457757f
  15. 27 Nov, 2001 2 commits
    • sof's avatar
      [project @ 2001-11-27 01:57:59 by sof] · 78a0cc3d
      sof authored
      make prev. commit compile on non-win32 boxes
      78a0cc3d
    • sof's avatar
      [project @ 2001-11-27 01:51:23 by sof] · e30e0fb8
      sof authored
      Rearranged how the virtual timer 'subsystem' is brought up and down:
      
      * "int startVirtTimer(nat ms)" now starts the vtimer/ticker.
      * "int stopVirtTimer()" shuts down the ticker.
      
      i.e., removed install_vtalrm_handler() and initialize_virtual_timer().
      e30e0fb8
  16. 26 Nov, 2001 1 commit
    • simonpj's avatar
      [project @ 2001-11-26 12:58:17 by simonpj] · d6181fe1
      simonpj authored
      In the Win32 build, don't call initProfTimer unless PROFILING
      is on.  This mirrors the Unix deal.   Indeed initProfTimer
      isn't defined if PROFILING is on.
      
      I don't know how this works for anyone else on Win32!
      Sigbjorn: have I done this right, or am I misunderstanding?
      d6181fe1
  17. 22 Nov, 2001 1 commit
    • simonmar's avatar
      [project @ 2001-11-22 14:25:11 by simonmar] · db61851c
      simonmar authored
      Retainer Profiling / Lag-drag-void profiling.
      
      This is mostly work by Sungwoo Park, who spent a summer internship at
      MSR Cambridge this year implementing these two types of heap profiling
      in GHC.
      
      Relative to Sungwoo's original work, I've made some improvements to
      the code:
      
         - it's now possible to apply constraints to retainer and LDV profiles
           in the same way as we do for other types of heap profile (eg.
           +RTS -hc{foo,bar} -hR -RTS gives you a retainer profiling considering
           only closures with cost centres 'foo' and 'bar').
      
         - the heap-profile timer implementation is cleaned up.
      
         - heap profiling no longer has to be run in a two-space heap.
      
         - general cleanup of the code and application of the SDM C coding
           style guidelines.
      
      Profiling will be a little slower and require more space than before,
      mainly because closures have an extra header word to support either
      retainer profiling or LDV profiling (you can't do both at the same
      time).
      
      We've used the new profiling tools on GHC itself, with moderate
      success.  Fixes for some space leaks in GHC to follow...
      db61851c
  18. 21 Nov, 2001 1 commit
    • sof's avatar
      [project @ 2001-11-21 20:55:10 by sof] · b88636e4
      sof authored
      initialize_virtual_timer: Robustified win32 version; don't
      assume that the minimal resolution is one millisec, consult
      the underlying impl via timeGetDevCaps().
      b88636e4
  19. 13 Nov, 2001 1 commit
  20. 14 Aug, 2001 1 commit
    • sewardj's avatar
      [project @ 2001-08-14 13:40:07 by sewardj] · bc5c8021
      sewardj authored
      Change the story about POSIX headers in C compilation.
      
      Until now, all C code in the RTS and library cbits has by default been
      compiled with settings for POSIXness enabled, that is:
         #define _POSIX_SOURCE   1
         #define _POSIX_C_SOURCE 199309L
         #define _ISOC9X_SOURCE
      If you wanted to negate this, you'd have to define NON_POSIX_SOURCE
      before including headers.
      
      This scheme has some bad effects:
      
      * It means that ccall-unfoldings exported via interfaces from a
        module compiled with -DNON_POSIX_SOURCE may not compile when
        imported into a module which does not -DNON_POSIX_SOURCE.
      
      * It overlaps with the feature tests we do with autoconf.
      
      * It seems to have caused borkage in the Solaris builds for some
        considerable period of time.
      
      The New Way is:
      
      * The default changes to not-being-in-Posix mode.
      
      * If you want to force a C file into Posix mode, #include as
        the **first** include the new file ghc/includes/PosixSource.h.
        Most of the RTS C sources have this include now.
      
      * NON_POSIX_SOURCE is almost totally expunged.  Unfortunately
        we have to retain some vestiges of it in ghc/compiler so that
        modules compiled via C on Solaris using older compilers don't
        break.
      bc5c8021
  21. 02 Mar, 2001 1 commit
    • simonmar's avatar
      [project @ 2001-03-02 10:52:15 by simonmar] · ac76dbc4
      simonmar authored
      Don't context switch on the timer if the flag +RTS -C0 is given.  This
      gives us reliable/repeatable runs with -C0 (I've been running with a
      similar change for months now, debugging is virtually impossible
      without it).
      ac76dbc4
  22. 27 Feb, 2001 1 commit
    • rrt's avatar
      [project @ 2001-02-27 12:43:45 by rrt] · 6339f4b0
      rrt authored
      mingwin "fixes": getourtimeofday now returns the right units, and awaitEvent
      fudged to use WinSock select(), so that although it doesn't work for file
      handles, at least it doesn't cause nasty crashes; instead it just blocks.
      6339f4b0
  23. 13 Feb, 2001 1 commit
    • rrt's avatar
      [project @ 2001-02-13 11:10:28 by rrt] · 7b76c2c1
      rrt authored
      Use MM timers on Windows even when not profiling, as threadDelay needs it
      to work properly.
      
      Flush stdout when quitting (in RtsUtils), as Linux glibc probably works now,
      and it reveals error messages that are otherwise truncated when one's
      program segfaults.
      7b76c2c1
  24. 06 Oct, 2000 1 commit
  25. 11 Sep, 2000 1 commit
    • rrt's avatar
      [project @ 2000-09-11 15:04:08 by rrt] · 1448475b
      rrt authored
      Implemented gettimeofday on Windows by calling GetTickCount(). This
      only seems to have a resolution of 1/100s, but that's just about OK
      for threadDelay, which only needs 50 ticks per second.
      1448475b
  26. 25 Aug, 2000 1 commit
    • simonmar's avatar
      [project @ 2000-08-25 13:12:07 by simonmar] · 5a4ec937
      simonmar authored
      Change the way threadDelay# is implemented.
      
      We now use a list of sleeping threads sorted in increasing order by
      the time at which they will wake up.  This avoids us having to
      traverse the entire queue on each context switch.
      5a4ec937
  27. 03 Aug, 2000 1 commit
    • simonmar's avatar
      [project @ 2000-08-03 11:28:35 by simonmar] · 66f7a41d
      simonmar authored
      Implement +RTS -C<n>, the context switch interval flag.  This was
      previously advertised in the usage message, but there was a note in
      the Users' Guide stating that it didn't work.  Anwyay, I'm going to
      consider it a bug and backport to 4.08.1.
      66f7a41d
  28. 17 Jul, 2000 1 commit
  29. 20 Jun, 2000 1 commit
  30. 03 Apr, 2000 1 commit
  31. 21 Mar, 2000 1 commit
  32. 20 Mar, 2000 1 commit
    • andy's avatar
      [project @ 2000-03-20 09:42:49 by andy] · 90a6918a
      andy authored
      Adding an alternative to the "delay" system used for
      threads that are waiting for time to pass.
      
      This works on a target time basis, eliminating the
      need to use the ticky style counter.
      
      It is only enabled under:
      
      #if defined(INTERPRETER) && !defined(HAVE_SETITIMER)
      90a6918a
  33. 14 Mar, 2000 1 commit
    • sof's avatar
      [project @ 2000-03-14 01:43:27 by sof] · cfab6b90
      sof authored
      * 'inlined' subset of the MM protos needed to compile this module, i.e.,
        don't require whoever does a 'make' in ghc/rts/ to have extended their
        <windows.h>
      * right Win32 proto for handle_tick()
      cfab6b90
  34. 28 Feb, 2000 1 commit
  35. 13 Jan, 2000 1 commit
    • simonmar's avatar
      [project @ 2000-01-13 12:40:15 by simonmar] · be587a37
      simonmar authored
      - remove AllBlocked scheduler return code.  Nobody owned up to having
        created it or even knowing what it was there for.
      
      - clean up fatal error condition handling somewhat.  The process
        exit code from a GHC program now indicates the kind of failure
        for certain kinds of exit:
      
      	general internal RTS error	254
      	program deadlocked		253
      	program interrupted (ctrl-C)	252
      	heap overflow			251
      	main thread killed		250
      
        and we leave exit codes 1-199 for the user (as is traditional at MS,
        200-249 are reserved for future expansion, and may contain
        undocumented extensions :-)
      be587a37
  36. 01 Dec, 1999 1 commit
  37. 16 Sep, 1999 1 commit
    • sof's avatar
      [project @ 1999-09-16 08:33:54 by sof] · f2419006
      sof authored
      Disable timer ticks on 'pure' Win32 platforms unless really needed
      (for profiling) -- no reason to enable it elsewhere as the Win32 bits
      doesn't currently support thread{Delay,Wait{Read,Write}}#
      f2419006
  38. 25 Aug, 1999 1 commit
    • simonmar's avatar
      [project @ 1999-08-25 16:11:43 by simonmar] · c6ab4bfa
      simonmar authored
      Support for thread{WaitRead,WaitWrite,Delay}.  These should behave
      identically to the 3.02 implementations.
      
      We now have the virtual timer on during all program runs, which ticks
      at 50Hz by default.  This is used to implement threadDelay, so you
      won't get any better granularity than the tick frequency
      unfortunately.  It remains to be seen whether using the virtual timer
      will have a measurable impact on performance for non-threadDelaying
      programs.
      
      All operations in the I/O subsystem should now be non-blocking with
      respect to other running Haskell threads.  It remains to be seen
      whether this will have a measurable performance impact on
      non-concurrent programs (probably not).
      c6ab4bfa