Closed kakyoism closed 3 years ago
What you observe is Dart startup cost (which unfortunately has been on a slower side since Dart 2.0 made significant changes both to the type-system and how we run Dart code). You can do the following, to confirm:
$ time dart bin/client.dart
Greeter client received: Hello, world!
1.94 real 2.05 user 0.25 sys
$ dart --snapshot=bin/client.dart.snapshot bin/client.dart
Info: Compiling without sound null safety
$ time dart bin/client.dart.snapshot
Greeter client received: Hello, world!
0.26 real 0.26 user 0.04 sys
@kakyoism yes to both of your questions from the deleted comment.
What you are observing is a one time program compilation cost. Snapshotting can address that if startup matters.
You can also observe some warmup latency, you can further mitigate that by compiling your server with AOT compiler (dart2native
) instead of running it in JIT mode.
@kakyoism yes to both of your questions from the deleted comment.
What you are observing is a one time program compilation cost. Snapshotting can address that if startup matters.
You can also observe some warmup latency, you can further mitigate that by compiling your server with AOT compiler (
dart2native
) instead of running it in JIT mode.
Thank you so much. Compiling to aot does the job for me.
dartaotruntime client.aot
runs blazingly fast!