-
Notifications
You must be signed in to change notification settings - Fork 125
dartdoc runs too long - possible patterns #2615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Dartdoc's reference structure currently requires us to load the world to resolve references, and there is currently no way to cache dartdoc data structures for a package between runs. Therefore, packages with complex dependencies (including, unfortunately, packages that use Flutter) can take a long time to process. Neither issue is simple to correct because a single package could have different data structures associated with it based on dependencies resolved elsewhere. |
I've had really good results with profiling Dartdoc in Observatory before, and these packages would be great to use; they may indicate some pathological cases that Dartdoc doesn't handle well. For example, having one library with lots of |
@jcollins-g: Would it be feasible to do so? On pub.dev we could have a good control over the cached file, and the 10-20 seconds that we could potentially gain on a single run may accumulate to days really fast...
@srawlins: I've tried to profile the generation of
I could imagine two parts where there is a chance for significant performance gain for a (maybe) low effort:
|
As for I'm a bit at loss here: what would be the easiest hook into Our current entrypoint is relatively simple: https://github.com/dart-lang/pub-dev/blob/master/pkg/pub_dartdoc/bin/pub_dartdoc.dart |
Converting file writing to async will be a bit challenging because of the infectious nature of asynchronous code. I'm also not sure it will actually result in any performance improvement though because the writing has to occur somewhere. Probably the most direct way to reduce operating system overhead might be to write dartdoc data into a tar file with package:archive or similar. Although I've not used the package, it looks like it could be suitable both for storing the data in memory and preventing excessive I/O overhead. |
@jcollins-g: we are looking into using in-memory fs for now, as it allows us to use additional sanity checks with early abort capability (e.g. number of files and sizes), and also efficient archive creation. Can you please comment on what would be the easiest way to configure the mem fs into our dartdoc entry point? |
@isoos I am not certain what the best way is, it will depend on what you want to do with in-memory filesystem (for example, do you want to have all the original source code and the SDK stored there as well that Dartdoc will be reading, or just for output? Using it for all input is probably a much larger change.) If it is just for output, adding a way to override the |
@jcollins-g: We would intercept only the output. I'm not entirely sure how I could hijack the Would it be possible to add a |
|
Any estimate when this could happen and released? |
It would depend. We accept PRs if you want to add this feature; I can commit to spinning a release soon after it lands if need be. |
I wonder if this issue is still useful. Package colorz is too old to be rendered with modern dartdoc. |
Agreed, let's close this. The template system is already different since we filed this issue. |
We've started to track
dartdoc
run elapsed times on pub.dev, and on the recent runtimes, the following patterns emerged:The top-1000 slowest runs were using Flutter SDK 94.2% of the time (89% in top-100).
The longest to generate is
package:colorz
which only has a single (but long) Dart file and a simple class reference pattern. It seems that there may be some opportunities for improvements there by caching some calculations wrt. theColor
reference? Random sampling of slow packages shows that similar patterns (e.g. single file with lots ofint
const values).Another slow pattern is having a large number of public libraries like in
package:ews
.A more surprising pattern seems to be in
package:niku
, where both the number of libraries and the source code is relatively small, but uses extension methods a lot.I've attached the list of slow packages to this issue, in the order of decreasing run times: slow.txt
The above patterns were observed with
"dart": "2.12.2", "flutter": "2.0.4", "dartdoc": "0.42.0"
.The text was updated successfully, but these errors were encountered: