profiling a constructor?

Richard Eisenberg rae at richarde.dev
Sat May 23 21:17:02 UTC 2020


Thanks for all the responses. Yes, I'm looking for the number of allocations of a constructor; this is an allocations issue, not a retention/liveness issue. I'm not concerned about accesses (not even sure what that would mean). Adding this to -ticky would be very helpful -- and not just for me. For example, it would help us to know more precisely why !2249 (implementing BoxedRep) is mired in performance trouble: we could see how many more TyConApp nodes are created.

If this would be easy, is there someone who can guide me how to implement it? I am almost as clueless as someone who has never before gazed on GHC's code in these areas. (Or, I would be grateful for someone else to implement it, too.)

Thanks,
Richard

> On May 23, 2020, at 10:11 PM, Simon Peyton Jones <simonpj at microsoft.com> wrote:
> 
> This would be a sensible thing to be able to count with -ticky.  Not hard to add either.
> 
> (Richard is asking for number of allocations, not what is live at any moment.)
> 
> Simon
> 
> |  -----Original Message-----
> |  From: ghc-devs <ghc-devs-bounces at haskell.org> On Behalf Of Richard
> |  Eisenberg
> |  Sent: 23 May 2020 13:59
> |  To: GHC developers <ghc-devs at haskell.org>
> |  Subject: profiling a constructor?
> |  
> |  Hi devs,
> |  
> |  Is there a way to count the number of times a particular constructor is
> |  allocated? I might want to know, say, the total number of cons cells
> |  allocated over the course of a program, or (in my actual case) the total
> |  number of FunTy cells allocated over the course of a program.
> |  
> |  I can try to do this with an SCC. But it's very clunky:
> |  * The constructor may be used in a number of places; each such place
> |  would need the SCC.
> |  * SCCs can interfere with optimizations. In my use case, this would
> |  negate the usefulness of the exercise entirely, as I think some of the
> |  structures I wish to observe should never come into being, due to
> |  optimizations (e.g. case-of-known-constructor after inlining).
> |  
> |  Surely, the RTS must be able to count the number of times a constructor
> |  is used. But is there any way to access such a feature? If others agree
> |  that this would sometimes be helpful, perhaps we can build the feature.
> |  Now is not the first time I've wanted this.
> |  
> |  Thanks!
> |  Richard
> |  _______________________________________________
> |  ghc-devs mailing list
> |  ghc-devs at haskell.org
> |  http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs



More information about the ghc-devs mailing list