Avoid invoking pub for simple instances of "pub run" #24736
Labels
area-sdk
Use area-sdk for general purpose SDK issues (packaging, distribution, …).
closed-obsolete
Closed as the reported issue is no longer relevant
customer-flutter
P2
A bug or feature request we're likely to work on
status-blocked
Blocked from making progress by another (referenced) issue
type-enhancement
A request for a change that isn't a bug
Currently,
pub run
invocations always invoke thepub
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:run
command is being invoked without any global arguments.run
are the executable name and, optionally,--checked
..pub
(for example, forpub run foo:bar
, the snapshot will be in.pub/bin/foo/bar.dart.snapshot
).pubspec.yaml
,pubspec.lock
, and.packages
files all exist.pubspec.yaml
.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 ofexec
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.
The text was updated successfully, but these errors were encountered: