-
Notifications
You must be signed in to change notification settings - Fork 119
[WIP] Multithreaded rendering #603
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
Closed
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
398cbb6
to
1acd002
Compare
4c6c5fd
to
c96391f
Compare
This reverts commit 9948600.
The work in this branch is outdated. All of this functionality has moved forward with #760. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #382.
Fixes #130.
This PR implements multithreaded rendering in Exokit. The goal is to break out every
window
context into its own thread of execution, which runs in parallel with all others.Reasoning
Bugs: The first reason to do this is that the existing
window
andWorker
implementations,vm-one
andwindow-worker
, are custom hacks that reimplement the node tick loop. In addition to a history of platform-specific Worker bugs in implementingimportScripts
, this interacts badly with some native node code in e.g. the TLS implementation, necessitating more out-of-thread routing hacks. All of these problems go away if we just use first-classworker_threads
, with native node support that does not need to be tracked or debugged.Starvation: The way the current tick loop works, the
window
tick execution is the only place thatwindow
contexts can make forward progress inlibuv
. That means that receiving request data is actually tied to the frame rate of the system -- this manifests as an inexplicable network slowness during loading. This is just howuv_run
works by default, and trying to schedule work on thewindow
instances is a problem that's 100% solved for us if we useworker_threads
.Performance: The way the current tick loop works, we run each
window
serially in the main loop (no other way to do it, since allwindow
s are bound to the same thread). By removing this restriction, we can run allwindow
raf ticks, and therefore rendering, in parallel. This especially helps in the case of reality tabs, where we potentially have many render layers in the same renderloop, all of which can logically run independently. Even if you don't care about reality tabs, this is nonetheless a performance improvement for the single-window case, since Exokit's main loop itself can now run in parallel with yourwindow
.Future features: This paves the way for more futuristic features such as desynching misbehaving reality tab layers and correcting the blend with a userspace reprojection.
Implementation
This requires Node 11 for
worker_threads
stability. Most notably, this required a port oflibnode.a
forarm64
/Magic Leap.Additionally, this completely rewrites
vm-one
andwindow-worker
in terms ofworker_threads
.Finally, this PR requires some light synchronization where the Exokit renderloop needs to access/call into the rafs and events of the
window
instances.Dependent PRs
Ingests avaer/window-worker@ed59b8d, avaer/vm-one#4.