Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stack bench --profile disables SMP mode #1808

Closed
ldcasillas-progreso opened this issue Feb 18, 2016 · 6 comments
Closed

stack bench --profile disables SMP mode #1808

ldcasillas-progreso opened this issue Feb 18, 2016 · 6 comments

Comments

@ldcasillas-progreso
Copy link

Version 1.0.3, Git revision 3f7b50fe598ec83eda5d393fe5b08a99ce5ac1e9 x86_64

With the repo here, as of this commit, I observe the following behavior. When I run this command, the benchmark runs in SMP mode:

stack bench --benchmark-arguments='theo1'

But when I run this command it runs in single-processor mode:

stack bench --profile --benchmark-arguments='theo1'

This can be seen from OS CPU usage report and the benchmarks themselves, which are testing the SMP speedup.

@mgsloan
Copy link
Contributor

mgsloan commented Feb 19, 2016

Hrm, here's an old fixed GHC bug that seems relevant ish: https://ghc.haskell.org/trac/ghc/ticket/886

In various places in the docs there are references to the "SMP version of the RTS", the "profiling version of the RTS". "version" is also sometimes swapped out with "flavor". Perhaps this is just wording that hasn't gotten pruned out of the docs, but this seems to suggest that there needs to be a profiling + smp variant of the RTS for this to work.

This is probably an upstream GHC issue, right? Have you gotten profiling to work with SMP in cabal?

@mgsloan mgsloan added this to the Support milestone Feb 19, 2016
@ldcasillas-progreso
Copy link
Author

Of course I haven't tried it in Cabal, Stack is so much better. :-)

The last comment in the ticket says:

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.

I'm on lts-3.20, so if the ticket is accurate then the GHC version should not be affected.

Also, I've now confirmed that the problem isn't just with benchmarks, it affects regular executables as well. If I do stack install --profile and then run the installed executable, I don't get SMP either.

@mgsloan
Copy link
Contributor

mgsloan commented Feb 19, 2016

Are you relying on -N coming from --with-rtsopts? In the past I found that specifying RTS opts on the commandline overrode --with-rtsopts, rather than extending. I'm not 100% sure that's the way it was working, but it certainly seemed to.

@ldcasillas-progreso
Copy link
Author

I am relying on that, but many of the bench.prof files that I'm getting from single-threaded runs show that the command that gets run is bench +RTS -N -p -RTS theo1. For example, if I run this command:

stack bench --profile --benchmark-arguments='theo1'

...the resulting bench.prof file starts like this:

Fri Feb 19 10:42 2016 Time and Allocation Profiling Report  (Final)

   bench +RTS -N -p -RTS theo1

total time  =       33.98 secs   (33980 ticks @ 1000 us, 1 processor)
total alloc = 30,263,454,656 bytes  (excludes profiling overheads)

And yet it ran on a single core. To my mind this suggests that a missing -threaded is the issue, but the following also runs on a single core:

stack bench --profile --ghc-options='-threaded' --benchmark-arguments='theo1'

@mgsloan
Copy link
Contributor

mgsloan commented Feb 21, 2016

Strange! In the past I've had a case where something reproduced with -N but not -N -p. Could be a related issue.

@mgsloan
Copy link
Contributor

mgsloan commented Jul 26, 2016

Closing since it doesn't seem to be a stack issue.

@mgsloan mgsloan closed this as completed Jul 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants