Opened 11 years ago

Closed 5 years ago

Last modified 5 years ago

#886 closed task (invalid)

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 Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

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 (18)

comment:1 Changed 11 years ago by simonmar

Milestone: 6.66.6.1
Summary: Profiling a threaded application with GHC-6.6rc.Profiling doesn't work with -threaded
Type: bugtask

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.

comment:2 Changed 11 years ago by simonmar

Architecture: x86Multiple
Component: CompilerRuntime System
difficulty: UnknownModerate (1 day)
Operating System: LinuxMultiple

comment:3 Changed 11 years ago by simonmar

Milestone: 6.6.16.8

comment:4 Changed 10 years ago by guest

Cc: shelarcy@… added

comment:5 Changed 10 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.

comment:6 Changed 10 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.

comment:7 Changed 10 years ago by simonmar

Milestone: 6.8 branch6.10 branch

comment:8 Changed 9 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.

comment:9 in reply to:  8 Changed 9 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.

comment:10 Changed 9 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.

comment:11 Changed 9 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.

comment:12 Changed 9 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.

comment:13 Changed 9 years ago by simonmar

difficulty: Moderate (1 day)Difficult (1 week)
Milestone: 6.10 branch_|_
Summary: Profiling doesn't work with -threadedProfiling doesn't work with SMP execution

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.

comment:14 Changed 9 years ago by simonmar

Architecture: MultipleUnknown/Multiple

comment:15 Changed 9 years ago by simonmar

Operating System: MultipleUnknown/Multiple

comment:16 Changed 8 years ago by simonmar

difficulty: Difficult (1 week)Difficult (2-5 days)

comment:17 Changed 5 years ago by morabbin

Resolution: invalid
Status: newclosed
Type of failure: None/Unknown

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.

comment:18 Changed 5 years ago by simonmar

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

Note: See TracTickets for help on using tickets.