[analyzer] Receive stdin in an isolate to increase responsiveness Before this CL, typing in a big file in IntelliJ on Windows could lead to longer and longer latency (read: taking longer and longer from you're finished writing and the code is error free until the editor doesn't report an error --- I've reached 40 seconds for a simple print statement in my testing). This is caused by a number of things; this CL fixes the issue by receiving data from stdin in an isolate. Background: * The IntelliJ plugin sends the whole file on every change in a file. Files can be big though, and e.g. `ast.dart` in the kernel package is almost 500 kb. * The IntelliJ plugin sends the data in chunks of size ~8192 bytes. * On Windows (but not Linux) it is also received in chunks of that size. * Darts `LineSplitter` is currently quadratic in behavior (https://github.com/dart-lang/sdk/issues/51167) (to be fixed with https://dart-review.googlesource.com/c/sdk/+/280100) Even with the fix of `LineSplitter`, when editing `ast.dart` in IntelliJ on Windows, (as long as one is typing fast enough) we'll create a longer and longer queue of messages (with more and more latency). In testing I reached ~40 seconds of latency, i.e. after I was done typing and there were no more errors it took ~40 seconds before the Analyzer and the editor agreed. I think what's happening is something like this: * You type a character in IntelliJ in Windows. * IntelliJ sends two requests: Updated content (the whole file, i.e. lots of data) and "give me completions". * You type another character (I seem to type one character every ~150 ms when typing) and it sends two new requests. * When receiving is slow it processes everything. So it updates the file and marks the file for being analyzed. Then it processes the completion requests which "forces" the file to be analyzed. This takes more than 150 ms, so it gets behind. More and more so for each character typed. Receiving in an isolate means that once the main thread receives (now via a `ReceivePort`) it receives more data and can now skip some of the completion requests meaning that it doesn't analyze the file for the "intermittent" updates. Change-Id: I43507412abfddcfb903d90d86226172b291bdb47 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280321 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Commit-Queue: Jens Johansen <jensj@google.com>
Dart is:
Optimized for UI: Develop with a programming language specialized around the needs of user interface creation.
Productive: Make changes iteratively: use hot reload to see the result instantly in your running app.
Fast on all platforms: Compile to ARM & x64 machine code for mobile, desktop, and backend. Or compile to JavaScript for the web.
Dart's flexible compiler technology lets you run Dart code in different ways, depending on your target platform and goals:
Dart Native: For programs targeting devices (mobile, desktop, server, and more), Dart Native includes both a Dart VM with JIT (just-in-time) compilation and an AOT (ahead-of-time) compiler for producing machine code.
Dart Web: For programs targeting the web, Dart Web includes both a development time compiler (dartdevc) and a production time compiler (dart2js).
Dart is free and open source.
See LICENSE and PATENT_GRANT.
Visit dart.dev to learn more about the language, tools, and to find codelabs.
Browse pub.dev for more packages and libraries contributed by the community and the Dart team.
Our API reference documentation is published at api.dart.dev, based on the stable release. (We also publish docs from our beta and dev channels, as well as from the primary development branch).
If you want to build Dart yourself, here is a guide to getting the source, preparing your machine to build the SDK, and building.
There are more documents on our wiki.
The easiest way to contribute to Dart is to file issues.
You can also contribute patches, as described in Contributing.