Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dart: Snapshots vs AOT

Tags:

dart

I am searching a lot about this great language and got myself on this page https://github.com/dart-lang/sdk/wiki/Snapshots but it didn't answer some questions:

  • What is the difference between a Snapshot and AOT? Which is faster and why?
  • Why the AOT generated on a Windows machine doesn't run on a Linux but a snapshot generated through dart --snapshot_kind=kernel does? What is "kernel"? Is it slower?
  • What is the difference from a Kernel Snapshot and a JIT Snapshot? Which is faster?
like image 654
Daniel Oliveira Avatar asked Jul 22 '19 20:07

Daniel Oliveira


1 Answers

  • With snapshots, nothing of your code (kernel snapshots) or only portions of your code (JIT snapshots) are pre-compiled into binary format. With AOT, all of your code gets pre-compiled to binary (platform specific) format. Pre-compiled binary code (AOT) is faster, because there is no need to compile code at runtime.
  • As mentioned above, AOT compiled code is transformed to platform specific binary code. Therefor you can not run a program AOT compiled for Windows on a Linux machine. With kernel snapshots, nothing of your code is pre-compiled. So it is portable between platforms, but must be compiled at runtime. So yes, this is slower.
  • Also as mentioned above, with kernel snapshots nothing of your code gets pre-compiled. With JIT snapshots, the program is executed in a test run and each part of the code that is executed, gets pre-compiled to platform specific binary format. So JIT snapshots is faster then kernel snapshots.
like image 133
Tidder Avatar answered Sep 28 '22 03:09

Tidder