Skip to content

Avoid invoking pub for simple instances of "pub run" #24736

Closed
@nex3

Description

@nex3

Currently, pub run invocations always invoke the pub executable. The executable is necessary to fully handle all the potential complexities of locating, configuring, and potentially re-snapshotting the executable, but it also involves a substantial performance hit, some of which comes unavoidably just from loading pub's code.

The best way to address this is to avoid invoking pub at all. It should be possible for the script that invokes pub to cheaply detect a pub run invocation that doesn't need special configuration, and to directly invoke the Dart executable. In particular, it should check:

  • That the run command is being invoked without any global arguments.
  • That the only arguments to run are the executable name and, optionally, --checked.
  • That the executable name is a single Dart identifier or two Dart identifiers separated by a colon.
  • That the corresponding executable snapshot exists in .pub (for example, for pub run foo:bar, the snapshot will be in .pub/bin/foo/bar.dart.snapshot).
  • That pubspec.yaml, pubspec.lock, and .packages files all exist.
  • That the snapshot has a more recent modification time than pubspec.yaml.
  • That the snapshot is compatible with the current dart executable (blocked on Add a facility to test whether a snapshot is up-to-date without running it #20802).

If all of these are true, the script should exec the snapshot (or whatever the equivalent of exec is on Windows).

This is blocked on:


I'm filing this in the SDK repo because it involves changing the POSIX and Windows pub wrapper scripts, which live here. Also, unfortunately, I don't have the shell expertise (especially with the Windows shell) to implement this myself. That said, I'm happy to work with someone who does have that expertise to get this implemented.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work onarea-sdkUse area-sdk for general purpose SDK issues (packaging, distribution, …).closed-obsoleteClosed as the reported issue is no longer relevantcustomer-flutterstatus-blockedBlocked from making progress by another (referenced) issuetype-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions