Open jensjoha opened 8 months ago
/cc @mraleph
Thanks for the great analysis, @jensjoha! The gardeners had noticed this test taking a long time as well, and filed https://github.com/dart-lang/sdk/issues/53278, which I have not looked at in a while. I'll land the dartdoc change and watch this bot.
TL;DR: Replacing records with classes in a few maps reduces runtime with ~28% and makes
SlowTypeTest
go from taking ~22% of the time to basically taking nothing. This is only true for JIT, not with AOT.Preface that isn't really that important I noticed that that for the try bots I was always waiting for two bots to finish, one of them being "pkg-linux-release-try" and that in particular the test "pkg/dartdev/test/commands/doc_test" took almost 10 minutes to run on the bot. Needing to clear my brain of what I was doing I thought I'd take a look. The test runs several iterations of "dart doc [...]" on some test code. To only look at one I applied this patch:
and ran the test - I now had an input and I could run dartdev with this input "stand alone": for me
time out/ReleaseX64/dart-sdk/bin/dart pkg/dartdev/bin/dartdev.dart doc /tmp/dartdevFAVRIP/myapp -v
(though to be fair I also randart pub get
in the temp dir to get rid of assert errors).One thing led to another and I eventually tried replacing some records with classes for keys in maps: (in the dir
third_party/pkg/dartdoc/
, e.g.$ pushd third_party/pkg/dartdoc/
):and the runtime (as reported by the tool itself) went from something like
to something like
--- something along the lines of a 28% improvement in runtime (not that I understand why it has to take that many seconds to generate docs for two almost empty files, but that's besides this particular point).
Important part
(compiling to dill, moving the file, also
cp out/ReleaseX64/dart out/ReleaseX64/dart-sdk/bin/
, then) Looking atperf report
for aperf record -g out/ReleaseX64/dart-sdk/bin/dart --generate_perf_events_symbols pkg/dartdev/bin/dartdev.dill.1 doc /tmp/dartdevFAVRIP/myapp -v
run, some things stood out:(there might be more, who knows).
after the patch, CallToRuntime is 10.79%, all the hash map stuff is <2%, DRT_TypeCheck is 0.34%, SlowTypeTest is 0.14% and SpecializeStubFor is 0.33%.
Interestingly, doing an aot-snapshot there's ~no difference in the runtimes, so this is appears to be a jit-only issue.