pub icon indicating copy to clipboard operation
pub copied to clipboard

Support globally activating packages using `dart compile exe`

Open johnpryan opened this issue 6 years ago • 11 comments
trafficstars

The "pub global activate" command currently creates a bash script that executes a "pub global run". Instead, pub could use the dart2native tool and place the binary directly in .pub-cache/bin.

johnpryan avatar Oct 21 '19 21:10 johnpryan

This also applies for local executables that you run with pub run. I believe that today pub creates a snapshot and runs it in an isolate, but it could just launch the native executable in a process with inherit stdio mode. This is basically the equivalent of the explicit pub global run which probably also spawns an isolate today.

jakemac53 avatar Oct 22 '19 14:10 jakemac53

Note that this would likely need to be opt in for the author of the binary. Native compilation adds some restrictions (on things like Isolates or mirrors) and so could break some binaries if we do it everywhere.

natebosch avatar Oct 22 '19 20:10 natebosch

Native compilation adds some restrictions (on things like Isolates or mirrors) and so could break some binaries if we do it everywhere.

Exactly, what's the motivation for using this for pub [global] run?

It'll probably improve startup performance a little.

jonasfj avatar Oct 23 '19 08:10 jonasfj

Also programs compiled with dart2native are AOT compiled, meaning they don't get JIT optimizations.

sigurdm avatar Oct 23 '19 10:10 sigurdm

It might be the better choice for users wanting slightly faster startup or for short-lived programs. I agree it should be opt-in though.

johnpryan avatar Oct 23 '19 16:10 johnpryan

Should we consider adding a new tag for it, e.g. ?

name: helloworld

executables:
  helloworld:
     runtime: aot

mit-mit avatar Nov 08 '19 10:11 mit-mit

Would that also work for a future flutter-desktop world?

sigurdm avatar Nov 08 '19 11:11 sigurdm

Does that make pub sort of a build system. I'm not saying we shouldn't, just that maybe we should think about all the things that will follow and do something more fully conceived.

Obviously, the next thing will be embedded resources.

jonasfj avatar Nov 08 '19 12:11 jonasfj

Pub doesn't need to be a general purpose build system, but it would be nice to provide ways to speed up start-up time by using the existing tools in the Dart SDK (either dart2native or app-jit snapshots). The kernel snapshots are leaving a couple hundred ms on the table, which might be longer than the actual program's execution time.

jonahwilliams avatar Jun 23 '20 01:06 jonahwilliams

The startup time is especially noticeable when using the bash completion package.

passsy avatar Jan 31 '21 18:01 passsy

I think annotating the type of compilation in the executables section of pubspec.yaml is a nice idea... We could have three values:

  • aot (compile to binary, dart compile exe)
  • snapshot
  • app-jit-snapshot (pre-warmed up with a first run during compilation, takes arguments to do the trial run...)

sigurdm avatar Mar 12 '24 15:03 sigurdm