Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,968
    • Issues 4,968
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 473
    • Merge requests 473
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #8308
Closed
Open
Created Sep 16, 2013 by Jan Stolarek@jstolarek

Resurrect ticky code for counting constructor arity

There is a dead piece of ticky profiling code that computes histograms of data constructor arities (including tuples) and size of vector returns. The function responsible is bumpHistogram in [[GhcFile(compiler/codeGen/StgCmmTicky.hs)]], which masks the commented out function bumpHistogramE. We can improve ticky profiling by resurrecting this dead code. There are following things that need to be done:

  1. Replace current no-op bumpHistogram with bumpHistogramE. Note that current implementation of bumpHistogramE computes constructor arity at runtime. This is unnecessary because we know arity at compile time so we can avoid runtime check by doing sth like this:
bumpHistogram lbl n = do
  let offset = n `min` 8
  emit (addToMem cLong
                 (cmmIndexExpr cLongWidth
                               (CmmLit (CmmLabel (mkRtsDataLabel lbl)))
                               (CmmReg (CmmInt (fromIntegral offset) cLongWidth)))
                 1)

Note that mkRtsDataLabel function does not exist anymore but we should be able to replace that call with mkCmmDataLabel rtsPackageId lbl (speculation).

  1. We need to declare arrays that will store histogram values. Declarations of variables used for storing ticky statistics are in [[GhcFile(includes/stg/Ticky.h)]]. We also need to initialize the declared array to contain only zeros.
  2. Having declared the arrays we need to fix printing of computed arities. This is done in [[GhcFile(rts/Ticky.c)]]. Note that there is a lot of code that is commented out (/* krc: comment out some of this stuff temporarily */) or disabled with #if FALSE pragma. We need to resurect *some* of it. There is a PR_HST macro for printing one histogram entry. This seems bad. We should probably rework the part of code responsible for printing out results of historgams.
  3. Current code counts arities from 0 to 8. Everything above 8 is put into the same bin as 8. This magical 8 is spread all over the code. We should declare a constant that is visible both in Haskell sources (see bumpHistogram in 1.) and RTS files and have all code behave properly depending on that constant - we should have loops instead of statically printing 9 elements of histogram array.
  4. Some ticky functions that count arity histograms are not used. For example tickyReturnNewCon should probably be called by cgConApp like this:
        ; emit =<< fcode_init
        ; tickyReturnNewCon
        ; emitReturn [idInfoToAmode idinfo] }

The above is a an outline, which should be fairly accurate, but unexpected things may show up along the way.

Trac metadata
Trac field Value
Version 7.7
Type Task
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Profiling
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system Unknown/Multiple
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking