<div dir="ltr">Nothing comes to mind.<div><br></div><div>If you know where the runtime is supposed to start you might try adding printfs in a few places that print out current-process-milliseconds (put a printf right before the call to profile-thunk too) and see if you can kind of hone in on something. You might find something surprising that would give a clue.</div>
<div><br></div><div>Robby</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jul 11, 2013 at 4:33 PM, Joe Gibbs Politz <span dir="ltr">&lt;<a href="mailto:joe@cs.brown.edu" target="_blank">joe@cs.brown.edu</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Thu, Jul 11, 2013 at 5:22 PM, Robby Findler<br>
&lt;<a href="mailto:robby@eecs.northwestern.edu">robby@eecs.northwestern.edu</a>&gt; wrote:<br>
&gt; Is it possible that the time is being spent in the expander or in other<br>
&gt; C-based code that would be hidden from the profiler?<br>
<br>
</div>I don&#39;t know quite what C-based code we might be touching, but I do<br>
know that our parser down to a racket/base program is no more than a<br>
couple hundred milliseconds for the programs we&#39;re working with.  I<br>
also tried emitting a more basic Racket module (via pretty-write and<br>
syntax-&gt;datum) from a parsed program and profiled that using<br>
`dynamic-require` rather than `eval` and got similar results.<br>
<br>
There are still macros in the emitted program, but there is no<br>
(intended) runtime expansion after the initial macros are dealt with.<br>
<br>
Are there other common C-based code entry points we might be running afoul of?<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
&gt;<br>
&gt; Robby<br>
&gt;<br>
&gt;<br>
&gt; On Thu, Jul 11, 2013 at 4:07 PM, Joe Gibbs Politz &lt;<a href="mailto:joe@cs.brown.edu">joe@cs.brown.edu</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; We&#39;re trying to profile some slow running programs in a #lang, and<br>
&gt;&gt; having some trouble getting believable results from the profiler.  In<br>
&gt;&gt; particular, it claims that most (e.g. 60-80%) of the time is spent in<br>
&gt;&gt;<br>
&gt;&gt; /usr/lib/racket/collects/profile/main.rkt:29:2<br>
&gt;&gt;<br>
&gt;&gt; We&#39;ve tried on up to 15-20 second runs of programs, and get the same<br>
&gt;&gt; result.  We&#39;ve tried making delay shorter (down to 0.01), and turned<br>
&gt;&gt; on #:threads.  We&#39;ve also tried setting<br>
&gt;&gt; (compile-context-preservation-enabled) to #t, and (eval-jit-enabled)<br>
&gt;&gt; to #f, and gotten roughly the same results.  Do we need to be running<br>
&gt;&gt; for minutes or hours?  Does the profiler interact badly with `eval`?<br>
&gt;&gt; We do see *some* calls to the runtime of the language, so they are<br>
&gt;&gt; recognized, but the time is clearly not being spent all at the top<br>
&gt;&gt; level of the profiler.<br>
&gt;&gt;<br>
&gt;&gt; Our test script is essentially:<br>
&gt;&gt;<br>
&gt;&gt; (time (profile-thunk (lambda ()<br>
&gt;&gt;   (eval-in-our-lang (file-&gt;string &quot;some-file&quot;))))<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; Some sample output is below.  We&#39;re confident that, for example, our<br>
&gt;&gt; implementation of `extend` is called quite often (and is attributed<br>
&gt;&gt; 12% of top-of-stack time), but I don&#39;t know if I should believe that<br>
&gt;&gt; proportion with respect to the other functions.  Any thoughts on where<br>
&gt;&gt; that 76% of time is actually spent?  Note that about 1/3 of the time<br>
&gt;&gt; is spent in GC, so maybe that is affecting the times that things are<br>
&gt;&gt; sampled?<br>
&gt;&gt;<br>
&gt;&gt; $ racket benchmarks.rkt<br>
&gt;&gt; Running list-creation<br>
&gt;&gt; Profiling results<br>
&gt;&gt; -----------------<br>
&gt;&gt;   Total cpu time observed: 15004ms (out of 15212ms)<br>
&gt;&gt;   Number of samples taken: 568 (once every 26ms)<br>
&gt;&gt;<br>
&gt;&gt; =============================================================<br>
&gt;&gt;                                   Caller<br>
&gt;&gt;  Idx    Total         Self      Name+src               Local%<br>
&gt;&gt;         ms(pct)       ms(pct)     Callee<br>
&gt;&gt; =============================================================<br>
&gt;&gt;  [1] 15004(100.0%)     0(0.0%)  [running body]<br>
&gt;&gt; ...ang/src/tests/benchmarks.rkt:##f<br>
&gt;&gt;                                   run-tests14 [4]      100.0%<br>
&gt;&gt; -------------------------------------------------------------<br>
&gt;&gt;                                   map/stx [19]         100.0%<br>
&gt;&gt;  [2]    26(0.2%)       0(0.0%)  temp155 (unknown source)<br>
&gt;&gt;                                   parse-block [18]     100.0%<br>
&gt;&gt; -------------------------------------------------------------<br>
&gt;&gt;                                   map/stx [19]         100.0%<br>
&gt;&gt;  [3]    14(0.1%)       0(0.0%)  parse-case-branch<br>
&gt;&gt; ...ang/src/lang/parser.rkt:219:0<br>
&gt;&gt;                                   parse-block [18]     100.0%<br>
&gt;&gt; -------------------------------------------------------------<br>
&gt;&gt;                                   [running body] [1]   100.0%<br>
&gt;&gt;  [4] 15004(100.0%)     0(0.0%)  run-tests14<br>
&gt;&gt; ...collects/rackunit/text-ui.rkt:243:0<br>
&gt;&gt;                                   apply-test-suite [5] 100.0%<br>
&gt;&gt; -------------------------------------------------------------<br>
&gt;&gt;                                   run-tests14 [4]      100.0%<br>
&gt;&gt;  [5] 15004(100.0%)     0(0.0%)  apply-test-suite<br>
&gt;&gt; ...it/private/test-suite.rkt:60:0<br>
&gt;&gt;                                   the-tests [6]        100.0%<br>
&gt;&gt; -------------------------------------------------------------<br>
&gt;&gt;                                   apply-test-suite [5] 100.0%<br>
&gt;&gt;  [6] 15004(100.0%)     0(0.0%)  the-tests (unknown source)<br>
&gt;&gt;                                   profile-thunk12 [7]  100.0%<br>
&gt;&gt; -------------------------------------------------------------<br>
&gt;&gt;                                   the-tests [6]        100.0%<br>
&gt;&gt;  [7] 15004(100.0%)     0(0.0%)  profile-thunk12<br>
&gt;&gt; ...t/collects/profile/main.rkt:9:0<br>
&gt;&gt;                                   run [8]              100.0%<br>
&gt;&gt; -------------------------------------------------------------<br>
&gt;&gt;                                   profile-thunk12 [7]  100.0%<br>
&gt;&gt;  [8] 15004(100.0%) 11402(76.0%) run<br>
&gt;&gt; /usr/lib/racket/collects/profile/main.rkt:29:2<br>
&gt;&gt;                                   extend [9]            12.8%<br>
&gt;&gt;                                   add-brand [10]         4.2%<br>
&gt;&gt;                                   string-map-ref5 [14]   4.1%<br>
&gt;&gt;                                   get-raw-field [11]     2.5%<br>
&gt;&gt;                                   eval-pyret/check [12]  0.2%<br>
&gt;&gt;                                   get-field [13]         0.2%<br>
&gt;&gt; -------------------------------------------------------------<br>
&gt;&gt;                                   run [8]              100.0%<br>
&gt;&gt;  [9]  1926(12.8%)   1798(12.0%) extend<br>
&gt;&gt; ...ts/pyret-lang/src/lang/runtime.rkt:545:0<br>
&gt;&gt;                                   foldr [15]             6.6%<br>
&gt;&gt; -------------------------------------------------------------<br>
&gt;&gt;                                   run [8]              100.0%<br>
&gt;&gt; [10]   636(4.2%)     636(4.2%)  add-brand<br>
&gt;&gt; ...pyret-lang/src/lang/runtime.rkt:524:0<br>
&gt;&gt; -------------------------------------------------------------<br>
&gt;&gt;                                   run [8]              100.0%<br>
&gt;&gt; [11]   372(2.5%)     372(2.5%)  get-raw-field<br>
&gt;&gt; ...t-lang/src/lang/runtime.rkt:439:0<br>
&gt;&gt; -------------------------------------------------------------<br>
&gt;&gt;                                   run [8]              100.0%<br>
&gt;&gt; [12]    26(0.2%)       0(0.0%)  eval-pyret/check<br>
&gt;&gt; .../src/tests/test-utils.rkt:60:0<br>
&gt;&gt;                                   pyret-&gt;racket7 [16]  100.0%<br>
&gt;&gt; -------------------------------------------------------------<br>
&gt;&gt;                                   run [8]              100.0%<br>
&gt;&gt; [13]    24(0.2%)       0(0.0%)  get-field<br>
&gt;&gt; ...pyret-lang/src/lang/runtime.rkt:445:0<br>
&gt;&gt;                                   string-map-ref5 [14] 100.0%<br>
&gt;&gt; -------------------------------------------------------------<br>
&gt;&gt;                                   get-field [13]         3.7%<br>
&gt;&gt;                                   run [8]               96.3%<br>
&gt;&gt; [14]   642(4.3%)     642(4.3%)  string-map-ref5<br>
&gt;&gt; ...ang/src/lang/string-map.rkt:8:0<br>
&gt;&gt; -------------------------------------------------------------<br>
&gt;&gt;                                   extend [9]           100.0%<br>
&gt;&gt; [15]   128(0.9%)     128(0.9%)  foldr<br>
&gt;&gt; ...ong/whalesong/lang/private/list.rkt:251:2<br>
&gt;&gt; -------------------------------------------------------------<br>
&gt;&gt;                                   eval-pyret/check [12]100.0%<br>
&gt;&gt; [16]    26(0.2%)       0(0.0%)  pyret-&gt;racket7<br>
&gt;&gt; ...yret-lang/src/lang/eval.rkt:34:0<br>
&gt;&gt;                                   parse-program [17]   100.0%<br>
&gt;&gt; -------------------------------------------------------------<br>
&gt;&gt;                                   pyret-&gt;racket7 [16]  100.0%<br>
&gt;&gt; [17]    26(0.2%)       0(0.0%)  parse-program<br>
&gt;&gt; ...ret-lang/src/lang/parser.rkt:33:0<br>
&gt;&gt;                                   parse-block [18]     100.0%<br>
&gt;&gt; -------------------------------------------------------------<br>
&gt;&gt;                                   parse-case-branch [3] 17.9%<br>
&gt;&gt;                                   temp155 [2]           41.0%<br>
&gt;&gt;                                   parse-program [17]    41.0%<br>
&gt;&gt; [18]    26(0.2%)       0(0.0%)  parse-block<br>
&gt;&gt; ...pyret-lang/src/lang/parser.rkt:56:0<br>
&gt;&gt;                                   map/stx [19]         100.0%<br>
&gt;&gt; -------------------------------------------------------------<br>
&gt;&gt;                                   map/stx [19]          10.8%<br>
&gt;&gt;                                   temp733 [21]          10.8%<br>
&gt;&gt;                                   parse-block [18]      78.5%<br>
&gt;&gt; [19]    26(0.2%)       0(0.0%)  map/stx<br>
&gt;&gt; ...uts/pyret-lang/src/lang/parser.rkt:28:0<br>
&gt;&gt;                                   temp155 [2]           33.8%<br>
&gt;&gt;                                   temp152 [22]          23.1%<br>
&gt;&gt;                                   temp733 [21]          10.8%<br>
&gt;&gt;                                   map/stx [19]          10.8%<br>
&gt;&gt;                                   parse-case-branch [3] 10.8%<br>
&gt;&gt;                                   temp596 [20]          10.8%<br>
&gt;&gt; -------------------------------------------------------------<br>
&gt;&gt;                                   map/stx [19]         100.0%<br>
&gt;&gt; [20]    14(0.1%)       0(0.0%)  temp596 (unknown source)<br>
&gt;&gt;                                   dots-loop [23]       100.0%<br>
&gt;&gt; -------------------------------------------------------------<br>
&gt;&gt;                                   map/stx [19]         100.0%<br>
&gt;&gt; [21]    14(0.1%)       0(0.0%)  temp733 (unknown source)<br>
&gt;&gt;                                   map/stx [19]         100.0%<br>
&gt;&gt; -------------------------------------------------------------<br>
&gt;&gt;                                   map/stx [19]         100.0%<br>
&gt;&gt; [22]    12(0.1%)      12(0.1%)  temp152 (unknown source)<br>
&gt;&gt; -------------------------------------------------------------<br>
&gt;&gt;                                   temp596 [20]         100.0%<br>
&gt;&gt; [23]    14(0.1%)      14(0.1%)  dots-loop (unknown source)<br>
&gt;&gt; -------------------------------------------------------------<br>
&gt;&gt; cpu time: 15228 real time: 15247 gc time: 5208<br>
&gt;&gt; ____________________<br>
&gt;&gt;   Racket Users list:<br>
&gt;&gt;   <a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
&gt;<br>
&gt;<br>
</div></div></blockquote></div><br></div>