[MLton] Question on profile.fun

Matthew Fluet fluet@cs.cornell.edu
Thu, 26 May 2005 17:10:06 -0400 (EDT)


The discussion and improvements to  -const 'Exn.keepHistory true'  had me 
thinking about other improvements to the profiling infra-structure.  I had 
the idea of adding the flags:

  -profile-exclude <regexp>  exclude files matching <regexp> from profile
  -profile-lib <regexp>  include library files matching <regexp> in profile

The latter would be a replacement for -profile-basis true.  The idea was 
that everything under  (!Control.libDir ^ "/sml")  (i.e., /build/lib/sml, 
/usr/lib/mlton/sml, etc.) would be considered libraries, and excluded from 
profiling by default.  When included in profiling, libraries would be 
granted shortened names, like "<basis>/list/list.sml" or 
"<cml>/core-cml/scheduler.sml".  The  -profile-lib <regexp>  would be 
applied to these shortened names, so  -profile-lib basis  should yield 
behavior very much like -profile-basis true.

I hoped (and continue to hope) that this could be accomplished within 
backend/profile.fun.  But, I have to admit I'm a little confused about the 
relationship between
  keepSource : SourceInfo.t -> bool	(line 182)
and
  enter : Push.t list * SourceInfo.t -> Push.t list * bool	(line 316)

In particular, I don't understand what the complicated condition at 
line 332 is trying to accomplish.  Nor, how to adapt these functions to 
handle the include/exclude regexps above.