[GHC] #9261: -S prints incorrect number of bound tasks
#9261: -S prints incorrect number of bound tasks ------------------------------------+------------------------------------- Reporter: edsko | Owner: Type: bug | Status: new Priority: low | Milestone: Component: Compiler | Version: 7.8.2 Keywords: | Operating System: Unknown/Multiple Architecture: Unknown/Multiple | Type of failure: None/Unknown Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | ------------------------------------+------------------------------------- In `Stats.c` we have: {{{ statsPrintf(" TASKS: %d (%d bound, %d peak workers (%d total), using -N%d)\n", taskCount, taskCount - workerCount, peakWorkerCount, workerCount, n_capabilities); }}} but I think `taskCount - workerCount` must be wrong, because `taskCount` is the _current_ number of tasks, while `workerAcount` is the _total_ number of workers (accumulating). I think it should be: {{{ statsPrintf(" TASKS: %d (%d bound, %d peak workers (%d total), using -N%d)\n", taskCount, taskCount - currentWorkerCount, peakWorkerCount, workerCount, n_capabilities); }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9261> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9261: -S prints incorrect number of bound tasks -------------------------------------+------------------------------------- Reporter: edsko | Owner: simonmar Type: bug | Status: new Priority: low | Milestone: Component: Runtime | Version: 7.8.2 System | Keywords: newcomer Resolution: | Architecture: Unknown/Multiple Operating System: | Difficulty: Easy (less than 1 Unknown/Multiple | hour) Type of failure: | Blocked By: None/Unknown | Related Tickets: Test Case: | Blocking: | Differential Revisions: | -------------------------------------+------------------------------------- Changes (by thomie): * cc: simonmar (added) * component: Compiler => Runtime System * difficulty: Unknown => Easy (less than 1 hour) * keywords: => newcomer * owner: => simonmar Old description:
In `Stats.c` we have:
{{{ statsPrintf(" TASKS: %d (%d bound, %d peak workers (%d total), using -N%d)\n", taskCount, taskCount - workerCount, peakWorkerCount, workerCount, n_capabilities); }}}
but I think `taskCount - workerCount` must be wrong, because `taskCount` is the _current_ number of tasks, while `workerAcount` is the _total_ number of workers (accumulating). I think it should be:
{{{ statsPrintf(" TASKS: %d (%d bound, %d peak workers (%d total), using -N%d)\n", taskCount, taskCount - currentWorkerCount, peakWorkerCount, workerCount, n_capabilities); }}}
New description: In `rts/Stats.c` we have: {{{ statsPrintf(" TASKS: %d (%d bound, %d peak workers (%d total), using -N%d)\n", taskCount, taskCount - workerCount, peakWorkerCount, workerCount, n_capabilities); }}} but I think `taskCount - workerCount` must be wrong, because `taskCount` is the _current_ number of tasks, while `workerAcount` is the _total_ number of workers (accumulating). I think it should be: {{{ statsPrintf(" TASKS: %d (%d bound, %d peak workers (%d total), using -N%d)\n", taskCount, taskCount - currentWorkerCount, peakWorkerCount, workerCount, n_capabilities); }}} -- -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9261#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9261: -S prints incorrect number of bound tasks -------------------------------------+------------------------------------- Reporter: edsko | Owner: thomie Type: bug | Status: new Priority: low | Milestone: Component: Runtime System | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by thomie): * keywords: newcomer => * owner: simonmar => thomie Comment: @edsko: I think the code is correct ''as is''. `taskCount` is not decremented when a worker task is stopped, but only when `freeMyTask` is called, which frees the task bound to the current thread. So `taskCount` is the current number of bound tasks + the total number of worker tasks. I suggest to just add a comment to the definition of `taskCount`: `// currentBoundCount + workerCount`. Do you agree? -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9261#comment:2> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9261: -S prints incorrect number of bound tasks -------------------------------------+------------------------------------- Reporter: edsko | Owner: thomie Type: bug | Status: patch Priority: low | Milestone: 7.12.1 Component: Runtime System | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: Phab:D746 -------------------------------------+------------------------------------- Changes (by thomie): * status: new => patch * differential: => Phab:D746 * milestone: => 7.12.1 -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9261#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9261: -S prints incorrect number of bound tasks -------------------------------------+------------------------------------- Reporter: edsko | Owner: thomie Type: bug | Status: patch Priority: low | Milestone: 7.12.1 Component: Runtime System | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: Phab:D746 -------------------------------------+------------------------------------- Comment (by edsko): I'm not sure to be honest. I reported this because I (thought I) was getting incorrect numbers reported, not because I was looking at the source code. I was looking at the source code only _because_ I was getting strange numbers. But I've forgotten the details; if you're sure it's correct.. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9261#comment:4> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9261: -S prints incorrect number of bound tasks -------------------------------------+------------------------------------- Reporter: edsko | Owner: thomie Type: bug | Status: patch Priority: low | Milestone: 7.12.1 Component: Runtime System | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: Phab:D746 -------------------------------------+------------------------------------- Comment (by thomie): Well, I've only studied the source code, I didn't actually run anything.. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9261#comment:5> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9261: -S prints incorrect number of bound tasks -------------------------------------+------------------------------------- Reporter: edsko | Owner: thomie Type: bug | Status: patch Priority: low | Milestone: 7.12.1 Component: Runtime System | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: | Blocking: | Differential Revisions: Phab:D746 -------------------------------------+------------------------------------- Comment (by Thomas Miedema <thomasmiedema@…>): In [changeset:"5449b25d02cca0c4ae706c9152f5f2c6107fe711/ghc"]: {{{ #!CommitTicketReference repository="ghc" revision="5449b25d02cca0c4ae706c9152f5f2c6107fe711" Clarify meaning of the RTS `taskCount` variable In #9261, there was some confusion about the meaning of the taskCount stats variable in the rts. It turns out that taskCount is not decremented when a worker task is stopped (i.e. from workerTaskStop), but only when freeMyTask is called, which frees the task bound to the current thread. So taskCount is the current number of bound tasks + the total number of worker tasks. This makes the calculation of the current number of bound tasks in rts/Stats.c correct _as is_. [skip ci] Reviewed By: austin Differential Revision: https://phabricator.haskell.org/D746 }}} -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9261#comment:6> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
#9261: -S prints incorrect number of bound tasks -------------------------------------+------------------------------------- Reporter: edsko | Owner: thomie Type: bug | Status: closed Priority: low | Milestone: 7.12.1 Component: Runtime System | Version: 7.8.2 Resolution: fixed | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: None/Unknown | Unknown/Multiple Blocked By: | Test Case: Related Tickets: #8124 | Blocking: | Differential Revisions: Phab:D746 -------------------------------------+------------------------------------- Changes (by thomie): * status: patch => closed * resolution: => fixed * related: => #8124 Comment: The code seems correct to me, so I'm closing this. But if you think you really do see weird numbers reported, of course reopen. Note that if your code doesn't explicitly call `hs_thread_done` (#8124), the number of bound tasks never decreases. So `taskCount` would be the sum of the total number of bound tasks and the total number of worker tasks ever created in that case. -- Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9261#comment:7> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler
participants (1)
-
GHC