-
Notifications
You must be signed in to change notification settings - Fork 17
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
Performance and sequencing characteristics of loader thread #129
Comments
I don’t think anything on that PR affects As far as I understand things, I’m not sure what you mean by “the user thread;” normal Node apps have only one thread, and if For the rest of it, I think the best way to get to the bottom of these questions would be for you to add some tests to the off-thread branch. Cover the various scenarios you’re discussing here, and have the expected result of the test match what you think should happen, and if that isn’t what occurs then we can discuss. |
I think the scenario cannot happen with the current PR, as the user thread would have its own ESM loader thread. It's still interesting to discuss the outcomes in case this is ever implemented (but I suppose would need to be opt-in).
Currently the worker assumes there can be at most one sync request at a time, so we would need to find some clever way to work around that.
Currently we are using
That's an interesting use case, could you write a test for that? |
I'm thinking ahead to the future where CJS can be handled by loaders, too. This is confusing, I'll try to update the OP to make this clearer.
I see. Is a future change going to collapse the multiple loader threads into a single loader thread, shared across all main and user threads? What's the current plan? |
Currently, you can specify whichever loaders for you worker thread, it doesn't inherit from the parent thread. This feature is not going away, as it seems a common enough use case to have a different loading mechanism for a |
Ok, I don't necessarily want it to be one way or the other, so long as the docs mention its behavior, whatever that is. |
The use-case is to avoid creating 2x copies of a transpiler and static analysis service. This service is used to transpile both
I'm also curious if quibble needs this: #124 (comment) |
FYI the version that has landed is a bit different from the time we discussed this, now the worker never locks itself. Having a test would still be interesting I think, if someone wants to contribute that, that would be awesome. |
Related to nodejs/node#44710 but I want to extract here so it can outlive that PR
It would be great to have written down the expected sequencing behavior of the loader thread. I'm not sure if "sequencing" is the correct term, but I would like to understand how the thread's workload tasks run concurrently or sequentially.
Past revisions of the off-thread PR forced certain tasks to run sequentially, where you would otherwise assume they are happening concurrently. Hopefully that is no longer the case. I'm hoping to verify by asking this question.
Scenarios
sync request from one thread blocking sync request from another
import.meta.resolve
calls to the loader thread which must communicate withsome-remote-process://takes-100ms-to-load/package.json
import.meta.resolve
calls to the loader thread which must communicate withsome-remote-process://also-takes-100ms-to-load/package.json
When (future) main thread makes 20x synchronous
require.resolve
calls, can each run synchronously in the loader thread? Or does the loader thread need to spin its event loop, handling a single request every tick?require.resolve
behavior can be tweaked in-thread, synchronously (fast)require.resolve
tweaks require spinning loader thread's event loop (slow) or can that also be done synchronously?When loader thread is blocked by atomics because it has no work, can a message posted to
globalPreload
port
wake it up?The text was updated successfully, but these errors were encountered: