dartdart-server

Why JIT & AOT has same performance when using Dart in server app?


In flutter application there is a lot of difference between JIT and AOT compilation when running the app, but in server application there is a small difference and sometimes AOT mode is slower than JIT. why this happen? is that means dart for server app is not optimized so much in AOT mode? in which case its good to use JIT mode?

for anyone want to test you can use this repo


Solution

  • AOT will be smaller (you can skip the full SDK) and startup faster – no JIT.

    An interesting detail: JIT will likely always be faster for long-running processes because the JIT compiler will optimize the code over time using information about how the process is executing.

    The AOT compiler does a best-guess optimization given details of the code on disk, but with no runtime information.

    We recommend the AOT model for serverless or micro-services that need to cold-start quickly and likely won't run a long time.

    If you have services that are long-running or where you really care about maximum possible performance (with less concern for startup time or deploy size) you may want to stick with JIT.