[GHC] #15402: The settings and behaviour of idle GC are very confusing

#15402: The settings and behaviour of idle GC are very confusing -------------------------------------+------------------------------------- Reporter: nh2 | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.6.1 Component: Runtime | Version: 8.4.3 System | Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- This extracting the issue between comments * https://ghc.haskell.org/trac/ghc/ticket/13497#comment:3 and * https://ghc.haskell.org/trac/ghc/ticket/13497#comment:14 into their own issue. There are a few problems problems (as of GHC 8.4.3): **1) You can't disable idle GC.** * This is contrary to the [https://downloads.haskell.org/~ghc/8.4.3/docs/html/users_guide/runtime_contr... #rts-flag--I%20%E2%9F%A8seconds%E2%9F%A9 manual], which says `Specifying -I0 disables the idle GC.`. * Passing `+RTS -I0` will run the idle GC a few times and then it will stop. [https://ghc.haskell.org/trac/ghc/ticket/13497#comment:10 Detailed here]. * It will run in intervals of `0.3` seconds (which is claimed to be the default for `-I` in the manual). **2) Giving the default for `+RTS -I` explicitly, namely `+RTS -I0.3`, changes the behaviour.** * With it given, idle GC will run every 0.3 seconds. * With it not given, it will run for a few times at 0.3 second and then stop. * This is exactly the behaviour of `-I0`. So if the manual said "the default for `-I` is `-I0`, that would be (perversely) more accurate. **3) The docs suggest idle GC is only in effect with `-threaded`.** * [https://downloads.haskell.org/~ghc/8.4.3/docs/html/users_guide/runtime_contr... #rts-flag--I%20%E2%9F%A8seconds%E2%9F%A9 manual "In the threaded and SMP versions of the RTS (see -threaded ...)."] * But idle GC settings like `+RTS -I` clearly also affect the nonthreaded RTS. **4) The concept of running the idle GC "for a little while" is a bit dubious in my opinion.** * Its [https://ghc.haskell.org/trac/ghc/ticket/13497#comment:13 origin as a power-saving mechanism] is sensible. * But it makes things "weird": When you look at `strace`, then first there's `SIGVTALRM` going on (because the idle GC timer of 0.3 seconds is checked against in each timer signal tick of 0.02 seconds by default), then after some time they suddenly stop. Of course `SIGVTALRM` occurring can also have effects on underlying library calls (syscalls return with `EINTR`), so (at least in non`-threaded`) a simple idling Haskell program creates some time-dependent behaviour on C libraries being used. * This makes debugging signal issues and behaviour extra hard, if you constantly have to keep in mind "oh but in the next 0.3 seconds the program will behave like this, and then behaviour will change. When you're debugging with `strace`, you have to be constantly aware whether or not the current output you read is inside or outside that time window. * But I don't have an idea of how this could be improved without sacrificing something else, so I guess this point just remains as "weird" for now. ---- I think points 1-3 are fixable, we should perhaps * make `-I<thedefaultvalue>` behave the same as not giving `-I` * change the "default value" to something that reflects what the current default behaviour actually is * the actual possibilities for this option expressed in Haskell would be `data IdleGcMode = NoneAtAll | StoppingAfterSeconds Double | IntervalSeconds Double` * so perhaps we should change `-I` to allow passing the following values to it: * `-I<seconds>`, e.g. `-I0.3` to mean `IntervalSeconds 0.3` * `-I<seconds>stopping`, e.g. `-I0.3stopping` to mean `StoppingAfterSeconds 0.3` * `-I0` to mean `NoneAtAll` * and the default would be `-I0.3stopping` to reflect the current default. * fix the documentation to reflect all this -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15402 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15402: The settings and behaviour of idle GC are very confusing -------------------------------------+------------------------------------- Reporter: nh2 | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.8.1 Component: Runtime System | Version: 8.4.3 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by nh2): * keywords: => newcomer * milestone: 8.6.1 => 8.8.1 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15402#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15402: The settings and behaviour of idle GC are very confusing -------------------------------------+------------------------------------- Reporter: nh2 | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: 8.8.1 Component: Runtime System | Version: 8.4.3 Resolution: | Keywords: newcomer Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by simonmar): Re (1), can you demonstrate it? I just tried `ghci +RTS -S -I0` and it definitely disabled the idle GC. (this was with current master) I do see it doing two idle GCs when I would expect just one. I'm not sure why that is. Re (2) I think you might be talking about the non-threaded RTS. With the threaded RTS, -I0.3 is the default, with the non-threaded RTS -I0 is the default. This probably needs to be documented. It probably never occurred to me that someone might use `-I` with the non-threaded RTS. For (3) yes I think the docs need to be updated. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/15402#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#15402: The settings and behaviour of idle GC are very confusing
-------------------------------------+-------------------------------------
Reporter: nh2 | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone: 8.8.1
Component: Runtime System | Version: 8.4.3
Resolution: | Keywords: newcomer
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Ben Gamari
participants (1)
-
GHC