Ticket #886 (closed task: invalid)

Opened 7 years ago

Last modified 4 months ago

Profiling doesn't work with SMP execution

Reported by: Lemmih Owned by:
Priority: normal Milestone: _|_
Component: Runtime System Version: 6.5
Keywords: Cc: shelarcy@…
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Difficult (2-5 days)
Test Case: Blocked By:
Blocking: Related Tickets:

Description

Compiling a Hello World program with -threaded and -prof results in a binary that segfaults immediately. This is with GHC-6.5.20060831.

$ cat Test.hs
module Main where
main = putStrLn "Hello world"
$ ../ghc-6.5.20060831/usr/bin/ghc -threaded -prof Test.hs -o test
$ ./test
Segmentation fault
$ ghc-6.4.1 -threaded -prof Test.hs -o test
$ ./test
Hello world

Change History

  Changed 7 years ago by simonmar

  • summary changed from Profiling a threaded application with GHC-6.6rc. to Profiling doesn't work with -threaded
  • type changed from bug to task
  • milestone changed from 6.6 to 6.6.1

The profiling subsystem isn't thread-safe at all, so can't be used with -threaded. I've made GHC 6.6 emit an error and refuse to compile rather than generate a crashing binary.

Later, we should fix this. A Big Giant Lock around the profiling subsystem is probably sufficient - it will introduce a bottleneck with -N2 and greater, but it should be ok with single processor runs.

  Changed 7 years ago by simonmar

  • difficulty changed from Unknown to Moderate (1 day)
  • os changed from Linux to Multiple
  • component changed from Compiler to Runtime System
  • architecture changed from x86 to Multiple

  Changed 6 years ago by simonmar

  • milestone changed from 6.6.1 to 6.8

  Changed 6 years ago by guest

  • cc shelarcy@… added

  Changed 6 years ago by guest

It must cause problem when someone want to optimise Haskell program.

If a programmer find that program is slow, then he profile and try to optimise it.H e find bottleneck long computing function, and he use thread to fix performance problem (Of course, bottleneck isn't memory efficiency in this case).

But now he can't profile his proram again. forkOS cause error without -threaded option.par can work without -threaded option, but profiler doesn't report correct result.

That's too bad.

  Changed 6 years ago by guest

And I think this problem affect Data Parallel Haskell developping process.

It seem that Data Parallel Haskell generate ndp package's code when vectorising Parallel Array.

But ndp can't build with perf or default build.

This cause problem when someone tries to use Data Parallel Haskell.

"Comleted" message isn't in Milestone 2, so I think development is late. But WorkPlan? suggests us that Data Parallel Haskell's ndp system will be release near future.

So we'll up against this situation soonly.

  Changed 6 years ago by simonmar

  • milestone changed from 6.8 branch to 6.10 branch

follow-up: ↓ 9   Changed 5 years ago by Frederik

Hello, it seems that this bug isn't very clear from the documentation or the GHC web page, can we be honest and update

 http://haskell.org/ghc/

where it says "Profiling is supported, both by time/allocation and various kinds of heap profiling."

to say "Profiling is supported, both by time/allocation and various kinds of heap profiling, provided you do not use threads."?

Thank you.

in reply to: ↑ 8   Changed 5 years ago by simonmar

Replying to Frederik:

to say "Profiling is supported, both by time/allocation and various kinds of heap profiling, provided you do not use threads."?

Just wanted to make sure there's no misunderstanding here: you can use threads with profiling just fine, the bug is that you can't use the -threaded option with profiling.

  Changed 5 years ago by Frederik

Hello, I was just thinking about that too, is it not common for people to use -threaded? Myself, I ran into this problem when I was trying to debug something that I found I had to compile with -threaded to work properly, but maybe I should have been using forkProcess.

  Changed 5 years ago by simonmar

Often there's no reason not to use -threaded (unless you want to profile, of course!). But it's only necessary if you want to (a) use multiple processors or (b) make FFI calls that don't block all threads.

  Changed 5 years ago by Frederik

OK, well that sounds like a significant chunk of functionality. I guess the benefit of working on non-commercial software is that you don't have to hide the shortcomings of your product. People who are interested to hear that GHC supports profiling are also likely to be interested to know to what extent it supports profiling. The fact that e.g. SMP is excluded is missing from  http://haskell.org/ghc/ and  http://haskell.org/ghc/docs/latest/html/users_guide/profiling.html, but that is one of the first questions that users who depend on SMP will want to know the answer to.

  Changed 5 years ago by simonmar

  • difficulty changed from Moderate (1 day) to Difficult (1 week)
  • summary changed from Profiling doesn't work with -threaded to Profiling doesn't work with SMP execution
  • milestone changed from 6.10 branch to _|_

I've now enabled -prof -threaded, it turns out that there weren't any major problems preventing their use together, we were just being conservative.

However, it is certainly a lot of work to make profiling work with SMP (+RTS -N2), and I don't think this is a high priority: you can just profile on a single CPU. Profiling parallel performance is another problem altogether (which is certainly on our radar). I've added a note to the profiling section of the user guide to mention that +RTS -N2 is not supported with profiling.

  Changed 5 years ago by simonmar

  • architecture changed from Multiple to Unknown/Multiple

  Changed 5 years ago by simonmar

  • os changed from Multiple to Unknown/Multiple

  Changed 4 years ago by simonmar

  • difficulty changed from Difficult (1 week) to Difficult (2-5 days)

  Changed 4 months ago by morabbin

  • status changed from new to closed
  • failure set to None/Unknown
  • resolution set to invalid

Closing as invalid, given this text from user guide for 7.6.1:

Combining -threaded and -prof is perfectly fine, and indeed it is possible to profile a program running on multiple processors with the +RTS -N option.

  Changed 4 months ago by simonmar

Right, this was fixed in 7.6.1. Nice ticket-weeding!

Note: See TracTickets for help on using tickets.