[Git][ghc/ghc][wip/con-info] 6 commits: Profiling by info table mode (-hi)

Matthew Pickering gitlab at gitlab.haskell.org
Mon Nov 23 11:13:36 UTC 2020



Matthew Pickering pushed to branch wip/con-info at Glasgow Haskell Compiler / GHC


Commits:
ff1846e0 by Matthew Pickering at 2020-11-23T10:42:39+00:00
Profiling by info table mode (-hi)

This profiling mode creates bands by the address of the info table for
each closure. This provides a much more fine-grained profiling output
than any of the other profiling modes.

The `-hi` profiling mode does not require a profiling build.

- - - - -
22256273 by Matthew Pickering at 2020-11-23T10:45:36+00:00
Add -finfo-table-map which maps info tables to source positions

This new flag embeds a lookup table from the address of an info table
to information about that info table.

The main interface for consulting the map is the `lookupIPE` C function

> InfoProvEnt * lookupIPE(StgInfoTable *info)

The `InfoProvEnt` has the following structure:

> typedef struct InfoProv_{
>     char * table_name;
>     char * closure_desc;
>     char * ty_desc;
>     char * label;
>     char * module;
>     char * srcloc;
> } InfoProv;
>
> typedef struct InfoProvEnt_ {
>     StgInfoTable * info;
>     InfoProv prov;
>     struct InfoProvEnt_ *link;
> } InfoProvEnt;

The source positions are approximated in a similar way to the source
positions for DWARF debugging information. They are only approximate but
in our experience provide a good enough hint about where the problem
might be. It is therefore recommended to use this flag in conjunction
with `-g<n>` for more accurate locations.

The lookup table is also emitted into the eventlog when it is available
as it is intended to be used with the `-hi` profiling mode.

Using this flag will significantly increase the size of the resulting
object file but only by a factor of 2-3x in our experience.

- - - - -
ff57d01f by Matthew Pickering at 2020-11-23T11:03:18+00:00
Add option to give each usage of a data constructor its own info table

The `-fdistinct-constructor-tables` flag will generate a fresh info
table for the usage of any data constructor. This is useful for
debugging as now by inspecting the info table, you can determine which
usage of a constructor caused that allocation rather than the old
situation where the info table always mapped to the definition site of
the data constructor which is useless.

In conjunction with `-hi` and `-finfo-table-map` this gives a more fine
grained understanding of where constructor allocations arise from in a
program.

- - - - -
ad2e6d1e by Matthew Pickering at 2020-11-23T11:06:01+00:00
Add whereFrom and whereFrom# primop

The `whereFrom` function provides a Haskell interface for using the
information created by `-finfo-table-map`. Given a Haskell value, the
info table address will be passed to the `lookupIPE` function in order
to attempt to find the source location information for that particular closure.

At the moment it's not possible to distinguish the absense of the map
and a failed lookup.

- - - - -
21fd02c3 by Matthew Pickering at 2020-11-23T11:10:42+00:00
Add test for whereFrom#

- - - - -
d3d30457 by Matthew Pickering at 2020-11-23T11:10:46+00:00
Add release notes for -hi, -finfo-table-map and -fdistinct-constructor-tables

- - - - -


30 changed files:

- compiler/GHC/Builtin/primops.txt.pp
- compiler/GHC/Cmm/CLabel.hs
- compiler/GHC/CoreToStg.hs
- compiler/GHC/Driver/CodeOutput.hs
- compiler/GHC/Driver/Flags.hs
- compiler/GHC/Driver/Hooks.hs
- compiler/GHC/Driver/Main.hs
- compiler/GHC/Driver/Session.hs
- compiler/GHC/Stg/CSE.hs
- + compiler/GHC/Stg/Debug.hs
- compiler/GHC/Stg/DepAnal.hs
- compiler/GHC/Stg/FVs.hs
- compiler/GHC/Stg/Lift.hs
- compiler/GHC/Stg/Lift/Analysis.hs
- compiler/GHC/Stg/Lift/Monad.hs
- compiler/GHC/Stg/Lint.hs
- compiler/GHC/Stg/Stats.hs
- compiler/GHC/Stg/Syntax.hs
- compiler/GHC/Stg/Unarise.hs
- compiler/GHC/StgToCmm.hs
- compiler/GHC/StgToCmm/Bind.hs
- compiler/GHC/StgToCmm/Closure.hs
- compiler/GHC/StgToCmm/DataCon.hs
- compiler/GHC/StgToCmm/Expr.hs
- compiler/GHC/StgToCmm/Monad.hs
- compiler/GHC/StgToCmm/Prim.hs
- compiler/GHC/StgToCmm/Prof.hs
- compiler/GHC/StgToCmm/Utils.hs
- + compiler/GHC/Types/IPE.hs
- compiler/GHC/Types/SrcLoc.hs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d23b9858b5306fef2e2f2371f08ca4a7c06e31de...d3d304578c90a96ccb3d97ac15af05b5e118fdbf

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/d23b9858b5306fef2e2f2371f08ca4a7c06e31de...d3d304578c90a96ccb3d97ac15af05b5e118fdbf
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20201123/cdae48dd/attachment-0001.html>


More information about the ghc-commits mailing list