Replies: 8 comments
-
Thanks for the kind words! I'd love an interpreter in official Dart, but I have a few reservations about it:
Let me know what you think. I do think convincing the Dart team is probably the most insurmountable obstacle here :p |
Beta Was this translation helpful? Give feedback.
-
Thanks for the reply!
Could you please point out some discussions? Then I can see why they refuse. I agree convincing them may be really hard :( But anyway I should see history discussions first to know why they refuse
Not sure about that. Indeed, when I am talking about Dart JIT on Android, I am still thinking it only runs app code in JIT mode (or even only changed app code) while flutter framework in AOT mode.
Ah interesting solution - why I did not realize this! Then there is already interpreter inside official dart? Btw did you check Bytedance fork? I have not found it and suspect it is not open source.
That's one place where dart_eval is very helpful :)
Hmm good question. Originally when I looked at the implementation, I thought it was very slow, because, for example, the stack is implemented as a Dart list. Since Dart list is so high level I originally thought that is the source of slowness. Could you please share a bit more insights about where the 12x slowness comes from? Maybe I can have some idea about optimizations.
Not sure about that, since React Native uses a C++ interpreter (the js interpreter) but no problem. |
Beta Was this translation helpful? Give feedback.
-
I am also worried about quality: The repo itself looks quite high quality already. However, if it has one bug in the whole repo, then someone will face big problem when using in real-world production app, because you know, a real-world app can be quite huge so touches each and every edge case. #59 may help somehow but I am not sure. Anyway, good job! |
Beta Was this translation helpful? Give feedback.
-
Thanks for your comments, these are definitely good questions :)
I am mostly just referring to the ones in flutter/flutter#14330.
Yes, this is ideal. But it may be very difficult - I will descibe this more below
I'd assume so :) I think most JITs have an interpreter component.
No, I think you are right. I can't find it.
Ok, I'm going to also describe here why it is hard to run app code in JIT and Flutter framework AOT. First, a simple example: var k = 1;
for (var i = 0; i < 100000; i++) {
k = k * k + 1;
} For this simple code, you are exactly right, that dart_eval is slower because of stuff like
In this case, an official Dart interpreter in C++ is easy to make, and would definitely be probably ~3-5x faster. But now Flutter: Wiget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text(widget.title)),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
const Text('You have pushed the button this many times:'),
Text('$_counter', style: Theme.of(context).textTheme.headline4),
],
)
);
} Actually here, the speed of the stack and bytecodes etc doesn't even matter that much because it is a very tiny portion of the overall speed. Most of the slowness of running this code is because every time it needs to create one of the Widgets, it must call out from the interpreter loop into a bridged Dart function that creates the widget, wraps it in a data structure ( This is also (potentially) hard to make in an official Dart interpreter. Effectively, now every function and class is a potential VM entrypoint (like
A little different because React is using JSCore which is built in to iOS I think... |
Beta Was this translation helpful? Give feedback.
-
You are right, that looks like a problem.
For this concrete problem I may have two cents: Maybe let the user (e.g. Flutter framework, or end user) choose it. For example, we may define it as "all framework code are AOT and put bridge around it". So Dart compiler do not need to make decision at all.
I may look into the details and see whether there are some potential improveable locations, if you are interested (#61). For example, not sure what "wrap" is (not check code yet), but if possible, we should avoid a wrapping, since that generate more objects, i.e. more indirection (slower) and more garbage (gc slower). Not sure whether I have mentioned before - another workaround is that, for computationlly heavy things, users can choose to make it AOT, then done. No worries about this slowness. |
Beta Was this translation helpful? Give feedback.
-
Btw could you please share some profiling data about your previous experiments? Would be great to see where a real app janks by looking at real data (e.g. line 10 is slow). |
Beta Was this translation helpful? Give feedback.
-
Yeah, I will do this at some point. But the reality is that for now, the speed of dart_eval is not really a problem, because it doesn't support enough features to make such complex apps that actually stress its performance. Once it has enough feature support then this will start to become a problem again. |
Beta Was this translation helpful? Give feedback.
-
I see. Look forward to the progress! |
Beta Was this translation helpful? Give feedback.
-
Hi, this project looks great and looks like a big amount of work! Excited to see it is still growing, and looking forward to seeing it in production :)
If I understand correctly, this looks like a Dart interpreter. Is it possible that we directly contribute to the dartlang repo and create an interpreter there? They use C++ so I guess the interpretation may run faster since we can control more low-level things.
Given that Dart already have JIT and AOT, adding an interpreted mode looks like something that will be accepted there.
So technically speaking, it should also be implementable.
I really want to see hot-update become reality. That's why I am suggesting this. Because I am quite afraid many people will not choose an interpreter that is not in the dart repository.
Another advantage is that, we can utilize all infra of dart sdk internals. There must be a lot of optimizations etc already there that we may even be able to reuse :)
Beta Was this translation helpful? Give feedback.
All reactions