Reputation: 21
Considering -
The file encoding,
The file size,
Inner data structure,
Startup time and etc.
And what is the main reason to choose dill file to start dart application? Which one has better startup time performance? And why?
Upvotes: 2
Views: 1901
Reputation: 657348
https://mrale.ph/dartvm/ is a great summary from a long-time Dart language team member.
As I understand it dill files and kernel snapshot are the same thing. dill
is just the name for the file extension used for Kernel (AoT snapshots)
Since Dart 2 VM no longer has the ability to directly execute Dart from raw source, instead VM expects to be given Kernel binaries (also called dill files) which contain serialized Kernel ASTs. snapshot
I assume what you actually want to know is the difference between AoT and JiT snapshots.
Initially snapshots did not include machine code, however this capability was later added when AOT compiler was developed. Motivation for developing AOT compiler and snapshots-with-code was to allow VM to be used on the platforms where JITing is impossible due to platform level restrictions.
Snapshots-with-code work almost in the same way as normal snapshots with a minor difference: they include a code section which unlike the rest of the snapshot does not require deserialization. This code section laid in way that allows it to directly become part of the heap after it was mapped into memory.
Startup time
AppJIT snapshots were introduced to reduce JIT warm up time for large Dart applications like dartanalyzer or dart2js. When these tools are used on small projects they spent as much time doing actual work as VM spends JIT compiling these apps.
So the main reason to use AOT is that JIT is not allowed (mainly iOS) or for short-lived commands where continual optimization based on code usage (hot-spot) would unlikely lead to any results.
For a discussion about the size see also https://github.com/dart-lang/sdk/issues/28655#issuecomment-428370886
Upvotes: 3
Reputation: 28552
I took a random dart program from the internet (a seemingly non functioning dart program, upgraded it to Dart 2.12/ sound null safety), and built all the outputs:
dart compile jit-snapshot main.dart -o calc.jit
The start up time is documented at dart compile.
Although kernel snapshots have reduced startup time compared to Dart code, they can have much slower startup than architecture-specific AOT output formats.
.dill
is the extension for portable snapshots (kernel). From Dart Compile docs:
Use the kernel subcommand to package up an app into a single, portable file that can be run on all operating systems and CPU architectures. A kernel snapshot contains a binary form of the abstract syntax tree (Kernel AST) for a Dart program.
Here’s an example of creating and running a kernel snapshot:
$ dart compile kernel bin/myapp.dart
Compiling bin/myapp.dart to kernel file bin/myapp.dill.
$ dart run bin/myapp.dill
Upvotes: 0