Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential optimization idea: Use another isolate (or multi isolate) to decode and prepare instructions as much as possible #65

Open
fzyzcjy opened this issue Oct 20, 2022 · 3 comments
Labels
performance Issue related to speed or performance

Comments

@fzyzcjy
Copy link

fzyzcjy commented Oct 20, 2022

Recall that, it is O(1) not O(N) to pass data back to main isolate, if the extra isolate send it via terminating message.

For example: from raw bytes to objects, including bridge methods etc. So that in main isolate we only need to call that (dynamic) function and done.

@maks
Copy link
Contributor

maks commented Oct 20, 2022

@fzyzcjy why do you expect using a separate Isolate will improve performance?
Do you have some specific plan on how to parallelise the work dart_eval currently does and why do you expect the overhead of passing data to/from a background Isolate will not out weigh any improvement from multi-threading?
Have you done any benchmarks for this?

@fzyzcjy
Copy link
Author

fzyzcjy commented Oct 20, 2022

@maks Hi, this is just an idea, but my logic is:

passing data to/from a background Isolate will not out weigh any improvement from multi-threading

Data pass from main to secondary, O(N): The raw bytes, say only 100KB (compressed), just downloaded from the backend server. IMHO memory-copy 100KB is quite fast. IIRC I did even pass 20MB big image to secondary isolate with O(N) copy and it was still not noticeable.

Work done in secondary:

a. decompress the bytes

b. decode into a list of ops, including finding the right method handler. so, for example, a operation may be "call String.subString", then the final Op should be a object constructed such as:

var that_decoded_op_should_be_like = Op((String s, int a, int b) => s.substring(a,b);

etc

Data pass from secondary to main: It is O(1), so no worries.

@ethanblake4
Copy link
Owner

Using an isolate to decode the EVC bytecode file into the list of ops is something I'll probably do eventually, once EVC files are commonly large enough to cause jank when loading. (Also, EVC loading is really unoptimized right now generally, so there's probably some other things I'll change first before this)

var that_decoded_op_should_be_like = Op((String s, int a, int b) => s.substring(a,b);

Doing a JIT-like thing with the ops is really interesting, beyond just the potential of using an Isolate. I'm a little wary that it actually may not be faster given the closure though, so this definitely needs further investigation.

@ethanblake4 ethanblake4 added the performance Issue related to speed or performance label Oct 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Issue related to speed or performance
Projects
None yet
Development

No branches or pull requests

3 participants