Removing use of dart:mirrors to allow AOT compile
#4139
Replies: 3 comments 8 replies
-
|
Been watching out for this one for a while now. Congratulations on the completion :) |
Beta Was this translation helpful? Give feedback.
-
|
I recently tried the AOT, and I thought it might be helpful to share the results: dart run build_runner build --delete-conflicting-outputs --force-jit
29s injectable_generator:injectable_builder on 526 inputs: 337 output, 189 no-op; spent 14s analyzing, 13s resolving, 2s building
4s injectable_generator:injectable_config_builder on 1949 inputs: 1 same, 1948 no-op; spent 3s building
10s graphql_codegen on 243 inputs: 243 same; spent 10s building
8s freezed on 417 inputs: 207 same, 210 no-op; spent 5s analyzing, 3s building
0s flutter_gen_runner on 1 input: 1 same
3s auto_route_generator on 218 inputs: 171 output, 47 no-op; spent 2s building, 1s analyzing
0s auto_route_generator:auto_router_generator on 1 input: 1 same
Built with build_runner/jit in 63s; wrote 961 outputs.AOT: 18s injectable_generator:injectable_builder on 526 inputs: 337 output, 189 no-op; spent 8s analyzing, 8s resolving, 1s building
4s injectable_generator:injectable_config_builder on 1949 inputs: 1 output, 1948 no-op; spent 3s building
8s graphql_codegen on 243 inputs: 243 output; spent 7s building
5s freezed on 417 inputs: 207 output, 210 no-op; spent 3s analyzing, 2s building
0s flutter_gen_runner on 1 input: 1 output
2s auto_route_generator on 218 inputs: 171 output, 47 no-op; spent 1s building
0s auto_route_generator:auto_router_generator on 1 input: 1 output
Built with build_runner/aot in 43s; wrote 961 outputs.So roughly %32, yes (🎉). However, I don't know if it is a characteristic of AOT or not, but from the moment the command is commenced until it actually starts building, it takes around 15 seconds. Just in AOT. JIT starts almost immediately. |
Beta Was this translation helpful? Give feedback.
-
|
Here, the build time was reduced from 23s to 9s! 👏👏👏 dart run build_runner build -vdart run build_runner build --force-aot -v |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
The latest
source_genrelease deprecatesTypeChecker.fromRuntime, because it uses mirrorshttps://pub.dev/documentation/source_gen/3.1.0/source_gen/TypeChecker/TypeChecker.fromRuntime.html
the intended replacement is the new
TypeChecker.typeNamedhttps://pub.dev/documentation/source_gen/3.1.0/source_gen/TypeChecker/TypeChecker.typeNamed.html
--the is a little looser than
TypeChecker.fromRuntime, it gets the name from the type you pass and then you should also explicitly pass a package name, so it matches name+package instead of full name+URI. This is usually what you want! As it doesn't make sense to stop detecting an annotation because it moved between files in the same package.The next
source_genmajor version bump will removeTypeChecker.typeNamed, and then it will be possible to compile AOT. I need to teachbuild_runnerto compile AOT in the meantime, work in progress :)One important note, the
source_genGeneratedForAnnotationusesTypeChecker.fromRuntime, you can keep using the annotation generator but you should start passing the annotation package name now, it will switch toTypeChecker.typeNamedwith the breaking release.https://pub.dev/documentation/source_gen/3.1.0/source_gen/GeneratorForAnnotation/GeneratorForAnnotation.html
Beta Was this translation helpful? Give feedback.
All reactions