
Hi GHC Team, I have a question for a research project. I'm looking at GHC's profiler, and the documentation says a profiling report displays "a break-down by cost centre of the most costly functions in the program". Here's an example of the report that I'm talking about: MAIN MAIN 102 0 0.0 0.0 100.0 100.0 CAF GHC.IO.Handle.FD 128 0 0.0 0.0 0.0 0.0 CAF GHC.IO.Encoding.Iconv 120 0 0.0 0.0 0.0 0.0 CAF GHC.Conc.Signal 110 0 0.0 0.0 0.0 0.0 CAF Main 108 0 0.0 0.0 100.0 100.0 main Main 204 1 0.0 0.0 100.0 100.0 fib Main 205 2692537 100.0 100.0 100.0 100.0 This example is under Section 8.1 of the GHC User's Guide https://downloads.haskell.org/ghc/latest/docs/users_guide/profiling.html#:~:text=GHC's%20profiling%20system%20assigns%20costs,to%20the%20enclosing%20cost%20centre. It looks like the numbers often add up to less than 100% for the %time, but I don't see any documentation on a threshold for what makes a cost centre "costly"—so I assume that "costly" means that it takes up any time whatsoever, and any cost centres that take up any time at all are included in the report? So perhaps the numbers under %time don't add up to 100% all the time because of rounding error or perhaps garbage collection? Or something else that is not profiled? Is that correct? Thanks, Celeste

Hi Celeste, It looks like by default only cost centers that account for at least 1% of either allocations or time are shown. But all cost centers are shown when the -pa flag is passed. See: https://downloads.haskell.org/ghc/latest/docs/users_guide/profiling.html?hig... and https://gitlab.haskell.org/ghc/ghc/-/blob/cf47b96f8b8100d9f9ad1b8121cbfb65fd... If you are processing these reports, it might be worth checking out the eventlog interface via the ghc-events library (if you haven't already). Cheers, Teo On Tue, Jul 30, 2024 at 3:58 PM Celeste Hollenbeck < celeste.hollenbeck@gmail.com> wrote:
Hi GHC Team,
I have a question for a research project. I'm looking at GHC's profiler, and the documentation says a profiling report displays "a break-down by cost centre of the most costly functions in the program". Here's an example of the report that I'm talking about:
MAIN MAIN 102 0 0.0 0.0 100.0 100.0 CAF GHC.IO.Handle.FD 128 0 0.0 0.0 0.0 0.0 CAF GHC.IO.Encoding.Iconv 120 0 0.0 0.0 0.0 0.0 CAF GHC.Conc.Signal 110 0 0.0 0.0 0.0 0.0 CAF Main 108 0 0.0 0.0 100.0 100.0 main Main 204 1 0.0 0.0 100.0 100.0 fib Main 205 2692537 100.0 100.0 100.0 100.0
This example is under Section 8.1 of the GHC User's Guide
It looks like the numbers often add up to less than 100% for the %time, but I don't see any documentation on a threshold for what makes a cost centre "costly"—so I assume that "costly" means that it takes up any time whatsoever, and any cost centres that take up any time at all are included in the report? So perhaps the numbers under %time don't add up to 100% all the time because of rounding error or perhaps garbage collection? Or something else that is not profiled?
Is that correct?
Thanks,
Celeste _______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs

Hi Celeste, You may already be aware, but there’s an alternative format to visualise profiles graphically. Instead of `-p`, use `-pj` to produce the profiling report in JSON format, and then load the resulting .prof file into speedscope.app https://www.speedscope.app/. Cheers, Rodrigo Mesquita
On 30 Jul 2024, at 15:57, Celeste Hollenbeck
wrote: Hi GHC Team,
I have a question for a research project. I'm looking at GHC's profiler, and the documentation says a profiling report displays "a break-down by cost centre of the most costly functions in the program". Here's an example of the report that I'm talking about:
MAIN MAIN 102 0 0.0 0.0 100.0 100.0 CAF GHC.IO.Handle.FD 128 0 0.0 0.0 0.0 0.0 CAF GHC.IO.Encoding.Iconv 120 0 0.0 0.0 0.0 0.0 CAF GHC.Conc.Signal 110 0 0.0 0.0 0.0 0.0 CAF Main 108 0 0.0 0.0 100.0 100.0 main Main 204 1 0.0 0.0 100.0 100.0 fib Main 205 2692537 100.0 100.0 100.0 100.0
This example is under Section 8.1 of the GHC User's Guide https://downloads.haskell.org/ghc/latest/docs/users_guide/profiling.html#:~:text=GHC's%20profiling%20system%20assigns%20costs,to%20the%20enclosing%20cost%20centre.
It looks like the numbers often add up to less than 100% for the %time, but I don't see any documentation on a threshold for what makes a cost centre "costly"—so I assume that "costly" means that it takes up any time whatsoever, and any cost centres that take up any time at all are included in the report? So perhaps the numbers under %time don't add up to 100% all the time because of rounding error or perhaps garbage collection? Or something else that is not profiled?
Is that correct?
Thanks,
Celeste _______________________________________________ ghc-devs mailing list ghc-devs@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
participants (3)
-
Celeste Hollenbeck
-
Rodrigo Mesquita
-
Teofil Camarasu