-
-
Notifications
You must be signed in to change notification settings - Fork 400
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Move Realm creation to another thread #433
Comments
Have a few more ideas relating to throwing some of the builtin construction into threads, beyond just Realm::create() Firstly, in regard to
To prevent the overhead of accessing the global object via a Mutex during execution of JS code, it might be better to have the threads that create the builtins instead send the object they create to the main thread via a channel, so the main thread will be the only thread that mutates the global env. This would also require updating every one of the Maybe to solve this, the worker threads can send construct them concurrently, but the main thread will add them only after they are all finished. But, this also presents a problem: some builtins need certain objects to exist during their own construction. For example, constructors that require the Next, if these objects are constructed concurrently, a further optimization might be to have a thread initialize groups of them so each thread has similar amounts of work. For example, one thread each for Might be an optimization of an optimization, and it would require testing and benchmarking at each step. I think it would be good to have the simple solution first, 1 thread per builtin, and try to see how that measures up to grouping up a few of them, since thread construction isn't free. |
At some point, execution could also be done in streaming, in which case, the realm would need to be ready when the execution starts (which would call the parser streamer). |
I've linked #419 with this because the optimisations in that should bring the realm creation time down significantly. Once that's done I will do another measure to see the impact |
I went back to the May 31st Looking at https://boa-dev.github.io/boa/dev/bench/ it seems Realm Creation has become considerably faster than it used to be, keeping this up in case in the future we want to introduce multi-threading once the builtins are more developed? |
The thing is that currently, we first tokenize + parse the whole program, and then we start creating the Realm. This creation is faster, but it could be parallelized with the lexing + parsing. We need it even if we fail to lex/parse, since we need to generate a Syntax Error. |
The problem with trying to implement a parallel initialization for Realm is that a lot of them depend on each other, even if that was not the case when we create a new |
Parsing and lexing should be independent of realm setup as neither of those tasks require use of the Gc, it’s only when you’re ready to execute it becomes a problem.
Has this changed? |
Not that I'm aware of, I might have mixed up the order, but the thing is that one waits for the other. |
We still need the realm to create a |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Realm creation is currently quite slow, and lexing and parsing doesn't start until this is finished. In the screenshot below we can see that Realm::create() runs on the main thread, and blocks everything else until its finished.
I think further optimisations can be done here to:
I'm also happy to discuss any other ideas or opportunities here
The text was updated successfully, but these errors were encountered: