Skip to content

Non-Dart Tool invocations aren't throttled #2728

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

Closed
gspencergoog opened this issue Aug 4, 2021 · 3 comments · Fixed by #2730
Closed

Non-Dart Tool invocations aren't throttled #2728

gspencergoog opened this issue Aug 4, 2021 · 3 comments · Fixed by #2730
Assignees
Labels
customer-flutter Issues originating from important to Flutter P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@gspencergoog
Copy link
Collaborator

gspencergoog commented Aug 4, 2021

If I swap the snippets tool in Flutter's repo with the following "slow_command"script:

#!/bin/bash

# Runs slowly because it never gets snapshotted.
dart /home/gspencer/code/flutter/dev/snippets/lib/main.dart "$@"

by using this config:

# This file is used by dartdoc when generating API documentation for Flutter.
dartdoc:
  # Before you can run dartdoc, the snippets tool needs to have a snapshot built.
  # The dev/tools/dartdoc.dart script does this automatically.
  tools:
    snippet:
      command: ["slow_command", "--type=snippet"]
      description: "Creates sample code documentation output from embedded documentation samples."
    sample:
      command: ["slow_command", "--type=sample"]
      description: "Creates full application sample code documentation output from embedded documentation samples."
    dartpad:
      command: ["slow_command", "--type=sample", "--dartpad"]
      description: "Creates full application sample code documentation output from embedded documentation samples and displays it in an embedded DartPad."
  errors:
    # Default errors of dartdoc:
    - duplicate-file
    - invalid-parameter
    - no-defining-library-found
    - tool-error
    - unresolved-export
    # Warnings that are elevated to errors:
    - ambiguous-doc-reference
    - ambiguous-reexport
    - broken-link
    - category-order-gives-missing-package-name
    - deprecated
    - ignored-canonical-for
    - missing-from-search-index
    - no-canonical-found
    - no-documentable-libraries
    - no-library-level-docs
    - not-implemented
    - orphaned-file
    - reexported-private-api-across-packages
    # - unknown-directive  # Disabled due to https://github.com/dart-lang/dartdoc/issues/2353
    - unknown-file
    - unknown-macro
    - unresolved-doc-reference

Then it seems to run out of control, and I can get my load average up to >1000:
Screen Shot 2021-08-04 at 8 11 30 AM

This doesn't happen if I keep the regular flutter config that runs a snapshotted version of the same script.

I'm trying to convert the snippet tool over to be run using pub global run from a package, and the lack of throttling is preventing that. I know that there is throttling code, but I just don't think it's working for non-dart tools.

@srawlins
Copy link
Member

srawlins commented Aug 4, 2021

@jcollins-g and I had both experienced some weird non-throttling behavior on-and-off, but couldn't really figure out what was going on. I think you've provided some valuable info here. I'd love to get this issue fixed.

@srawlins srawlins added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) customer-flutter Issues originating from important to Flutter P2 A bug or feature request we're likely to work on labels Aug 4, 2021
@gspencergoog
Copy link
Collaborator Author

gspencergoog commented Aug 4, 2021

I also tried reverting the dartdoc_options.yaml, and adding a 10-second pause into the snippet tool, and it does appear to throttle to 4 processes when it uses the snapshotting (i.e. when it's a Dart tool and not a shell script). I did notice an initial spike in that run when it had at least 50 running simultaneously, but it quickly calmed down to 4, so maybe there's some initialization pass that isn't throttled or something?

Incidentally, I think it would be good to look at the number of CPUs available instead of just hard coding four: my 72-core machine would be a lot faster to run dartdoc in that case (as would our CI when configured with more CPUs). I believe that Platform.numberOfProcessors has that information.

@gspencergoog
Copy link
Collaborator Author

@srawlins I have a fix for this. I'll post a PR this afternoon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-flutter Issues originating from important to Flutter P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants