-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
dart2native: support creating self-contained binary executables #36915
Comments
I think this feature is very useful for deployment. |
Just want to say: i really like flutter and Dart; every time i look into some introductions, i am waiting for AOT single binary to use it as main programming language overall 💯 So, this maybe thoughts of many people, which are interested in flutter and / or Dart itself, but waiting for AOT the last years. Very happy if it´s available 🥇 |
I also second the request for single (self-contained) binary output - this would be a welcome step in enabling e.g. multistage builds in Docker where we can throw out most of the dart run-time and get the container sizes down to something more manageable for FaaS and microservice deployments. |
@pmundt single binary would not be much smaller than AOT snapshot + AOT runtime combination you get now, because it would be just these two things linked together. In fact if you have multiple AOT compiled apps it would be better to not use single binary if you are concerned about the size - because you would just duplicate runtime. AOT runtime is already the smallest runtime version which has all unnecessary stuff removed |
Oh God I need this so much! It's amazing! Deploying my code and deliverying to my clients withouth worrying about dart vm setup, everything self-contained into a single executable file? Would be a dream! PLEASE..... JUST.......... DO IT! |
Very supportive. Need this, Expect! |
Can we get some update? How long will we stay here? There is nothing upcoming in changelog till now... Thanks 👍 |
Well, this is one of the best features after a long time. Do we have any language which is compiled and typed as well as high level and pretty much CONCISE + Supports OOP? At last we got Swift, but you know Apple right? they open sourced swift(that too a limited one with less libraries supported) to gain devs, so let's skip apple. Dart is the only concise, simple, compiled language which you can count on. |
Personally, I think Kotlin is better than Dart in many ways in language design. (Of course, Dart got its own niche, too.) And for JVM languages, now the new toy, Graalvm, looks really promising. Especially, It comes with tools to compile .class/.jar into a single standalone executable binary. No something like dartaotruntime needed, no accompanies (*.dill). Yes, it would be nice to see Dart having the same tools.
I used to have the same image as you. AoT should mean more performant, right? But actually, after playing a while with the new Dart AoT functionality and Graalvm native-image (both Dart and Java/Kotlin are static-typed languages), they all are slower, much slower, compared to the version run on JIT-enabled VM. (I used some computation-intensive benchmarks to do these tests: snapshot vs AoT and Jar vs binary from native-image) You can verify it by yourself. The advantage of AoT is actually the fast start-up time because no VM stuff needed to be initialized. Not the performance. I don't know all the factors that make JIT faster than AoT, but one thing I know that is interesting about Dart. When Dart VM does the JIT things, it keeps an un-optimized version and goes with another version with as aggressive optimization as it can. If that optimization went too far, it falls back to the safe version and tries again with something less aggressive. This approach really pushes the codes to its limit. On the other hand, AoT compilers must be conservative about the optimization. There are no chances to fix if the generated codes are wrong because the optimization is too aggressive. But JIT takes time, right? Fortunately, there is a mode, --snapshot-kind=app-jit, that let you train and save the optimized status. I didn't test it much. The default mode(--snapshot-kind=kernel) beats AoT already. |
javaddict have you benchmarked or just guessing. If we leave the almost negligible speed difference aside, JIT is a RAM hog compared to AOT. Also do you know Apple doesn't allow using JIT on their iPhones, though the main concern is security but the other reasons are memory usage and performance optimisations. Also Dart required AOT to support iOS. PS: one example where AOT beats the JIT, is in Haskell. Haskell is a very high level language which is very hard to optimise during compile time due to its pure functional nature and immutable data types, lazy data types, etc. However GHC(AOT) is always miles faster than Hugs(JIT implementation). The optimizations are possible because of Haskell's Type system. GHC is the main Haskell compiler now because who really wants to run their programs 3-5 times slower on JIT with RAM hogging? |
Performance comparison between AOT and JIT is very nuanced and highly dependant on a particular workload. In general Dart AOT can't necessarily devirtualize all the same calls that JIT can e.g. just declaring a variable as In any case - discussion of JIT vs AOT performance characteristics does not necessarily belong to this issue and should better be taken on other mediums (e.g. on Dart mailing list). |
Sorry. Not trying to start a serious discussion of JIT vs AOT here, nor to troll on it. I am fully aware of the importance and necessity of AOT in those cases @thomasb892 has mentioned and totally agree that the performance difference of JIT vs AOT goes case by case, just as @mraleph illustrated. I took some time to summarize my (not very strict) test results of the benchmarks listed here. |
@javaddict sorry, i downvoted you (#36915 (comment)) because this is a discussion about getting a tool to create a single binary out of the code. There is no discussion to compare against Java nor Kotlin, nor to replace native android programming. The only discussion background here is to create a single binary out of the box, because with Dart we have a language which is:
which means we are able to write mobile apps, web-apps and desktop-apps (which all will have their compiled format) and we are able to compile the whole server backend to a / several binaries. This is: to have a language which suites much needs and to have compiled binarys instead of naked code files, which is simply more safe and usable. In my intention this is not about AOT vs. JIT, vs. Kotlin, whatever. Simply: it is about generating single binaries. So, i would really like to have this feature 👍 |
I always thought that ahead-of-time compilation was meant to produce native executable that is system-dependent. AOT Wikipedia article also states that. But it looks |
AOT (ahead-of time) just means that the machine code is prepared during development, not during execution in production (as in a JIT, just-in-time, compiler inside a traditional VM; virtual machine). Strongly typed languages with garbage collection still need runtime systems, even when executing AOT-compiled machine code. This runtime system is responsible for performing dynamic type checks, and for freeing memory no longer used. |
Can we get a single binary that contains both runtime and machine code? I want to distribute a single file like golang without install dart runtime on other devices. @mit-mit |
Yes, that is what this bug tracks. We're getting pretty close. |
Hey looks cool, Dart VM version: 2.6.0-dev.3.0 on "linux_x64" is working fine. Are you going to or can we have the option to name the generated executable, Anyway on my i5 nuc - NUC6i5SYH real 0m0.011s time dart helloworld.dart real 0m0.129s |
Cool stuff, tested out with Ubuntu 19.10 with i7-8750H, seems useful for Cloud Run.
|
A simple dart2native approach has been implemented, with the caveat that re-signing the generated binaries might not be possible. If we wanted to remove our signature from the AOT runtime we could consider doing that with @mit-mit @mraleph Can we remove the D26 milestone from this issue and/or close it? |
@mkustermann excuse me, i do not fully understand. What does your comment above mean? Do you want to stop the work?
What does that mean? |
I can confirm success with dart2native - I'm able to reduce my container size from ~250MB to 25MB, which is a great improvement, especially as we begin to use Dart for cloud functions in OpenFaaS. An option for static linking so that we can toss out more of the runtime environment would be nice, and would likely bring this down to ~10MB, in line wither other languages (e.g. Golang). |
As asarnaak and sebe i have done some tests against startup time compared to C and Go, where Dart is ~20 times slower, but, all in all, this is a very big enhancement, and i would like to use Dart now whenever possible. For me, this issue is a game changer to all. Pretty cool! |
I've also written up some of our experiences in working on container size reduction, for anyone that is interested in this topic: https://medium.com/@paulmundt/experiments-with-dart-microservices-fa117aa408c7 |
@n8crwlr some operating systems (Windows and Mac OS X) have builtin support for signed executables. The way we implemented |
Basic functionality implemented - closing this issue. If signing becomes important - we will file a separate one for that. |
I do not need signing. Thank you very much for supporting the single binary 👍 |
Just wanted to say thanks, i wanted to use dart for a command line application about a month ago and found I couldn't package a single binary for my customer, so I had to skip it and write it in NodeS instead (it will likely need to be embedded into an interface at some point). Would have loved to use this - and now that its available I will definitely be using this in the future. IMO this is the final piece of the dart puzzle to go almost exclusively dart. So once again, a big thanks for listening to the community and prioritising a needed feature. |
Agreed with @rknell, dart team is doing an awesome work. Congratulations, and more than that, thank you! |
I'm having issues when I try to move the binary to the system bin path: $ dart2native main.dart -o fireutil
Generated: /home/cachapa/fireutil/bin/fireutil
$ ./fireutil
Utility to manage Firestore databases.
[...]
$ sudo mv fireutil /usr/local/bin
$ fireutil
Usage: dart [<vm-flags>] <dart-script-file> [<script-arguments>]
[...] |
I'm on the dev channel: $ dart --version
Dart VM version: 2.6.0-dev.5.0 (Thu Oct 3 15:21:01 2019 +0200) on "linux_arm" The changes you mentioned seem to be more recent. Any idea how long it'll take for them to reach the Debian dev channel? |
The latest version on dev channel, Normally when we release new versions they are pushed to all distribution channels, so I would assume the debian repository has this version as well. In fact they seem to be in our cloud storage bucket: |
My bad, I was running it on my Raspberry Pi and didn't realise there's no .deb for ARM. Thanks! |
Anyone knows if I can generate the binaries for Linux from a Windows 10 computer? There is any way of doing that? |
Unfortunately not. Right now cross compiling from Windows to Linux is not possible (and there is also no planned timeline for making this work) |
maybe Cygwin can help?
… Em 30 de out de 2019, à(s) 19:45, Daniel Oliveira ***@***.***> escreveu:
Anyone knows if I can generate the binaries for Linux from a Windows 10 computer? There is any way of doing that?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#36915?email_source=notifications&email_token=ABPJRXTTGLELT4ZAXVXTMETQRIE7NA5CNFSM4HL5KHX2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECWAHKI#issuecomment-548144041>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABPJRXTSW25YVUEC7TCKF53QRIE7NANCNFSM4HL5KHXQ>.
|
You can try WSL (Windows subsystem for Linux). I have used it much for such things in the past. You can work on the same files on both platforms (as long you are building a CLI). Than you will be able to compile on Windows for Windows and on WSL for Linux easily. But i have not used the all new WSL 2 since that. |
You could also use a CI provider, e.g. TravisCI |
This has now formally launched; for details see the blog post: https://medium.com/dartlang/dart2native-a76c815e6baf |
Neat! :-) I made an example repo that uses GitHub actions to compile on each platform and adds the output binaries as artifacts (for the trivial app it takes around 1min from pushing to having a zip file of binaries :-)) https://github.com/DanTup/dart-native-executables |
Feature request originally split from the related and now solved issue #34343 (comment).
Thanks to Dart 2.3 AOT mode compiling is now supported through the
dart2aot
utility.For easier deployment and usability creating a single binary executable file would be a great feature to have.
The text was updated successfully, but these errors were encountered: