-
Notifications
You must be signed in to change notification settings - Fork 278
Support for AOT compilation #669
Comments
What would be the benefit of AOT compilation for an Aqueduct application? |
Many :
Documentation in relation : https://github.com/dart-lang/site-www/blob/a66d468245b84451aa40574db4ba81ee09bd9515/src/_tutorials/server/get-started.md#8-compile-for-production |
How does this compare to snapshotting? A simple, snapshotted Aqueduct app is showing up as 39.6MB of runtime memory usage. What is the actual reduction in startup time? How is deployment easier? How is the Docker image 'lighter'? How is the overall performance improved compared to JIT for a long-running process like a server application? |
Memory usage are similar between snapshot jit and aot. Maybe not the best argument.
App-JIT snapshot vs App-AOT snapshot : https://github.com/dart-lang/sdk/wiki/Snapshots
No runtime, only dartaotruntime executable, your dart.aot and dart.aot.dill files (plus your assets if needed)
Cause of previous point, we don't need google dart image (with runtime) and we can use alpine image for example (maybe scratch with some effort ?)
Tests on my computer show me better performance overall for my simple REST API (response time, processing data). I don't have enough back to argue about long-running process (cause yes I know we loose one of the advantage of JIT on this point). |
I just fired up a snapshotted Aqueduct application and startup time was effectively instantaneous - I'm not sure applications that run for days/weeks/months at a time need a millisecond-order-of-magnitude improvement at startup. Is deployment really easier? If you're containerizing, I don't see much of a difference here? Is there a way to measure the size of a Docker image for an AOT vs. JIT compiled images? What are the actual savings quantified? Is there an example of this Dockerfile available? In your performance testing, have you accounted for JIT? I'm not sure how runtime performance would be any different once the VM is warmed up. What are the actual tests & their measurements you are evaluating here? |
In my case, I containerize my app but maybe not everybody ...
I created a sample angel application with 3 docker images (jit, snapshot & aot) (i'm using the official google dart image, aot use ubuntu image) : https://github.com/sriio/sample-dart-hello. Building images :
Images size :
Stats :
As I said before, I don't have enough back to argue much more on performance. Dart 2.3 is not actually official, I only tested with my case (REST API without templating, etc ...). I can't give you full bench or other. Btw, compare VM warmed up (optimized only for some critical paths and after a huge? delay and amount of calls) against an aot build is not the best idea imo. |
The disk size of the image is significant and worth looking at. There is not a way to disable mirrors right now. We will look at solutions for producing AOT builds. Thanks for putting together the numbers. |
Ok, good to hear. I updated the aot docker image in my sample project. It's even better
|
It would be great to have AOT compilation for the Aqueduct |
AOT for Aqueduct is currently under development. |
good job, thanks for sharing. |
It's gone be a killer feature for us ! |
Status update: The first phase of this effort is complete. The effort removed all reflection from the framework and moved it to a separate runtime library (that is used by default when running your application). The next phase will add a The end result is that you'll be able to run/debug quickly using the same way you do currently (using reflection). When you are ready to ship, you will run |
Hello, any news on this? |
Sure thing. Remaining effort:
|
@joeconwaystk Ok, thanks for the update! Following this thread with lot of interest anyway. 👍 |
hey @joeconwaystk thanks for the excellent support and hard work on aqueduct. looking forward to giving AOT a try on Cloud Run when its available |
Interested to move from Java to Dart on the backend, and Aqueduct came up as a leading choice. Learning from past experiences, we're looking into no-reflection libraries only. However, without AOT support (and killing reflection altogether) it's not going to happen unfortunateiy. Could you share an update on development @joeconwaystk? |
@joeconwaystk, any update on the remaining effort from 18 August? I'm running some aqueduct backends on a few resource-constrained machines and the reduction in memory would be hugely welcome. Thanks a ton for the awesome work already done so far on this overhaul! |
I am also interested on this. |
Thanks everyone for following up on this, it's clearly an exciting feature! I'll take a few moments here to outline some key things for you all to know: In working through this effort, it was identified that a dependency of Aqueduct also used mirrors ( Both For the purpose of timing: currently, our company is growing significantly and we do not have much time to allocate to the efforts described above. This growth will provide us with greater ability to apply effort to Aqueduct. Additionally, the upcoming holiday season will free up some time as most of our customers are off during that period. I would expect that effort can be wrapped up late Q4, but don't want to make any promises as our organizational growth is critical in the long-term. Thank you again for your interest in this feature, I am also looking forward to it! |
Great job @joeconwaystk! As the time goes on, dart gets even better. And few weeks ago, Dart just got a nice feature: support for creating self contained dart executables. That means, no dart sdk installation is needed to deploy dart projects, anymore! Check dart-lang/sdk#36915 Can't wait to see that on aqueduct! |
me also. That will be great thing. Looking on Flutter, AOT code is running 4 or more time faster |
Is it ready? |
The suffix .aot has no meaning here and, if you notice in the log, the executable is run directly. As an update, there are about 10 tests failing now and they are all related to one function call. |
@joeconwaystk If you don't mind me asking, what would be that particular function call that is causing the 10 tests to fail? Appreciate all the great efforts so far! |
from changelog but "aqueduct build" working on windows 10, just need to rename executable to aot to exe PS > mv .\web.aot .\web.exe |
Hi all. All of the tests are now passing. There is a pre-release available on pub (3.3.0-b1), but it some tricky package constraints have caused some issues with existing users of <3.2.1. Technically, you can run the build command once you have converted any relative path imports to @atik7 Good to hear on Windows. The mention in the CHANGELOG is there due to two things: the tests are not set up on Windows CI yet, and typically there are some path-related bugs that need to get ironed out. You can install the beta version with |
Thank you for enable AOT and passing tests. I just install 3.3.0-b1, and "aqueduct build" to compile a very simple entry project "try". However, I only find "Server aqueduct/1 started", only 1 thread. Is it caused by beta version? Could you advise for it? Thanks. |
Oh, please ignore it, I can use "try.exe -n 4" to start 4 threads. |
Thank you so much for the amazing work on this, Joe. It's a fantastic ad for Stable Kernel. If you hired remotely, I'd be applying already. 👍 I just tried to use version 3.3.0-b1 from pub against an existing aqueduct project that can be served without issue on versions 3.2.1 and 3.3.0. When running
It looks like So I think you need to update your version of I tried that on a local clone of this repo and it seemed to fix the issue. (I didn't notice any knock-on effects.) |
Both your aqueduct CLI an project's pubspec.yaml has to be version 3.3.0-b1. There is an issue with the pre-release on pub right now, but I have not had the time to correct it. Either way, this should probably get bumped to a 4.0 breaking change. |
Thanks for the fast response. Both my aqueduct CLI and project's pubspec.yaml show 3.3.0-b1, so I'm not sure that's the cause:
But if there's an issue with the pre-release on pub, then I'll wait for now anyway. Thanks again for the huge amount of effort you've put into this over the last few months. Seeing the aot version start-up instantly and run so quickly was very exciting. It will really help my docker-based deployments start quickly and keep memory use down. |
@benbarbersmith Just noticed your first comment and that you had mentioned working for SK remotely - this is something we are strongly considering now that Covid19 has tested us here and we have succeeded. I wanted to say I appreciate the comment you made, and apologies for not seeing it in my previous response. In your particular case, the solution is to tighten up that analyzer constraint, yes. I'm just slammed this week - if someone pushed a PR to tighten the constraint, I can commit to pushing a new pre-release version to pub sometime this week. |
Thanks @joeconwaystk - this is amazing. I just built and tested with the AOT binary and everything works for me with the analyzer-hack. The startup time is stellar and now I can finally get rid of the dart runtime on the server. |
What is the status of this? Thank you for the work |
I'm using this framework for a backend i'm writing. I've been following this thread and I'm hoping to launch my backend service with this. Please tell me this effort isn't abandoned! |
Not sure why people think this is abandoned... this is one of the best maintained backend packages I've ever seen. |
It's not abandoned, but it has certainly slowed down as we grapple with a post-Covid business landscape. This feature does exist in the 3.3.0-b1 release, but the dependency on analyzer caused issues with dependency resolution for non-prerelease users. I'd like to push a 4.0.0-b1 with this feature to pub this week. |
Why don't you use a builder (like json_serializable) for the ORM during dev-process. So it would be possible to start the server with >dart "appName" (JIT) or to compile the server with >dart2native + start. No more mirrors/reflections. |
$ aqueduct build
-- Aqueduct CLI Version: 4.0.0-b1
-- Aqueduct project version: 4.0.0-b1
Resolving ASTs...
Generating runtime...
Generated runtime at 'file:///{path-to}/heroes/build/generated_runtime/'.
Compiling package 'runtime'...
Package 'runtime compiled to 'file:///{path-to}/heroes/build/packages/runtime/'.
Compiling package 'aqueduct'...
Package 'aqueduct compiled to 'file:///{path-to}/heroes/build/packages/aqueduct/'.
Compiling package 'safe_config'...
Package 'safe_config compiled to 'file:///{path-to}/heroes/build/packages/safe_config/'.
Copying application package (from 'file:///{path-to}/heroes/')...
Application packaged copied to 'file:///{path-to}/heroes/build/packages/heroes/'.
Fetching dependencies (--offline --no-precompile)...
Finished fetching dependencies.
Compiling...
Generating AOT kernel dill.
Generating AOT snapshot.
Generating executable.
Marking binary executable.
Generated: /{path-to}/heroes/heroes.aot
Success. Executable is located at 'file:///{path-to}/heroes/heroes.aot'.
$ Very small size, instant startup time, fully working: $ du -hs heroes.aot
7.2M heroes.aot
$
$ file heroes.aot
heroes.aot: Mach-O 64-bit executable x86_64
$
$ ./heroes.aot
[INFO] aqueduct: Server aqueduct/1 started.
[INFO] aqueduct: PostgreSQL connecting, heroes@localhost:54322/heroes.
[INFO] aqueduct: GET /heroes?name=ap 48ms 200
[INFO] aqueduct: GET /heroes 4ms 200 |
Can |
IMO you cannot. And I don't even see it as a healthy approach. That error is simply related to the fact that currently Aqueduct uses Related to the need:
|
Ah, such a pity. Aqueduct ORM's |
Hey, I'm using local packages which I'm importing with
This package is 2 directives up, so it is specified in
Any help? |
Ran into this issue myself today, replacing the local packages with absolute paths in pubspec.yaml fixed it for me. |
When will available 4.0 version (usable) ? |
Dart 2.9.2 and Aqueduct 4.0.0-b1 ist not compatible. The aqueduct build command crashed with the following error: -- Aqueduct CLI Version: 4.0.0-b1
Are you aware of these error? Do I have do downgrade dart to 2.8 to successfully build an aot snapshot of my server??? |
Same issue with dart 2.10.2 |
^ same issue with 2.10.3 and 2.11 beta |
With Dart 2.3, you can compile your backend ahead of time but it doesn't work with aqueduct ...
Steps to reproduce:
Download Dart 2.3 here : http://gsdview.appspot.com/dart-archive/channels/stable/raw/2.3.0/sdk/
Create a new aqueduct project with
aqueduct create test_project
Go to test_project and run
dart2aot bin/main.dart bin/main.dart.aot
Problem:
You get this error :
Cause:
Like the case of Flutter, the package 'mirrors' doesn't work with aot compilation ... No workaround, just find a way to replace it (with reflectable for example which is ok with aot)
The text was updated successfully, but these errors were encountered: