-
-
Couldn't load subscription status.
- Fork 33.6k
[v10.x] process: split bootstrappers by threads that can run them #21866
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
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
This patch split part of the bootstrappers into three files:
- `lib/internal/process/main_thread_only.js`: contains bootstrappers
that can only be run in the main thread, including
- `setupStdio` for the main thread that sets up `process.stdin`,
`process.stdout`, `process.error` that may interact with external
resources, e.g. TTY/File/Pipe/TCP sockets
- `setupProcessMethods` that setup methods changing process-global
states, e.g. `process.chdir`, `process.umask`, `process.setuid`
- `setupSignalHandlers`
- `setupChildProcessIpcChannel` that setup `process.send` for
child processes.
- `lib/internal/process/worker_thread_only.js`: contains bootstrappers
that can only be run in the worker threads, including
- `setupStdio` for the worker thread that are streams to be
manipulated or piped to the parent thread
- `lib/internal/process/per_thread.js`: contains bootstrappers
that can be run in all threads, including:
- `setupAssert` for `process.assert`
- `setupCpuUsage` for `process.cpuUsage`
- `setupHrtime` for `process.hrtime` and `process.hrtime.bigint`
- `setupMemoryUsage` for `process.memoryUsage`
- `setupConfig` for `process.config`
- `setupKillAndExit` for `process.kill` and `process.exit`
- `setupRawDebug` for `process._rawDebug`
- `setupUncaughtExceptionCapture` for
`process.setUncaughtExceptionCaptureCallback` and
`process.hasUncaughtExceptionCaptureCallback`
Hopefully in the future we can sort more bootstrappers in
`boostrap/node.js` into these three files and further group
them into functions that can be run before creating the
snapshot / after loading the snapshot.
This patch also moves most of the `isMainThread` conditionals
into the main bootstrapper instead of letting them scattered around
special-casing different implementations.
PR-URL: nodejs#21378
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
|
cc @targos |
targos
approved these changes
Jul 18, 2018
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
targos
pushed a commit
that referenced
this pull request
Jul 18, 2018
This patch split part of the bootstrappers into three files:
- `lib/internal/process/main_thread_only.js`: contains bootstrappers
that can only be run in the main thread, including
- `setupStdio` for the main thread that sets up `process.stdin`,
`process.stdout`, `process.error` that may interact with external
resources, e.g. TTY/File/Pipe/TCP sockets
- `setupProcessMethods` that setup methods changing process-global
states, e.g. `process.chdir`, `process.umask`, `process.setuid`
- `setupSignalHandlers`
- `setupChildProcessIpcChannel` that setup `process.send` for
child processes.
- `lib/internal/process/worker_thread_only.js`: contains bootstrappers
that can only be run in the worker threads, including
- `setupStdio` for the worker thread that are streams to be
manipulated or piped to the parent thread
- `lib/internal/process/per_thread.js`: contains bootstrappers
that can be run in all threads, including:
- `setupAssert` for `process.assert`
- `setupCpuUsage` for `process.cpuUsage`
- `setupHrtime` for `process.hrtime` and `process.hrtime.bigint`
- `setupMemoryUsage` for `process.memoryUsage`
- `setupConfig` for `process.config`
- `setupKillAndExit` for `process.kill` and `process.exit`
- `setupRawDebug` for `process._rawDebug`
- `setupUncaughtExceptionCapture` for
`process.setUncaughtExceptionCaptureCallback` and
`process.hasUncaughtExceptionCaptureCallback`
Hopefully in the future we can sort more bootstrappers in
`boostrap/node.js` into these three files and further group
them into functions that can be run before creating the
snapshot / after loading the snapshot.
This patch also moves most of the `isMainThread` conditionals
into the main bootstrapper instead of letting them scattered around
special-casing different implementations.
PR-URL: #21378
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Backport-PR-URL: #21866
Reviewed-By: Michaël Zasso <[email protected]>
|
Landed in 581390c |
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.
This patch split part of the bootstrappers into three files:
lib/internal/process/main_thread_only.js: contains bootstrappersthat can only be run in the main thread, including
setupStdiofor the main thread that sets upprocess.stdin,process.stdout,process.errorthat may interact with externalresources, e.g. TTY/File/Pipe/TCP sockets
setupProcessMethodsthat setup methods changing process-globalstates, e.g.
process.chdir,process.umask,process.setuidsetupSignalHandlerssetupChildProcessIpcChannelthat setupprocess.sendforchild processes.
lib/internal/process/worker_thread_only.js: contains bootstrappersthat can only be run in the worker threads, including
setupStdiofor the worker thread that are streams to bemanipulated or piped to the parent thread
lib/internal/process/per_thread.js: contains bootstrappersthat can be run in all threads, including:
setupAssertforprocess.assertsetupCpuUsageforprocess.cpuUsagesetupHrtimeforprocess.hrtimeandprocess.hrtime.bigintsetupMemoryUsageforprocess.memoryUsagesetupConfigforprocess.configsetupKillAndExitforprocess.killandprocess.exitsetupRawDebugforprocess._rawDebugsetupUncaughtExceptionCaptureforprocess.setUncaughtExceptionCaptureCallbackandprocess.hasUncaughtExceptionCaptureCallbackHopefully in the future we can sort more bootstrappers in
boostrap/node.jsinto these three files and further groupthem into functions that can be run before creating the
snapshot / after loading the snapshot.
This patch also moves most of the
isMainThreadconditionalsinto the main bootstrapper instead of letting them scattered around
special-casing different implementations.
PR-URL: #21378
Reviewed-By: Gus Caplan [email protected]
Reviewed-By: Anna Henningsen [email protected]
Reviewed-By: Jeremiah Senkpiel [email protected]