Repository navigation
Closed
Labels
feature-requestRequest for new features or functionalityfreeze-slow-crash-leakVS Code crashing, performance, freeze and memory leak issuesinsiders-releasedPatch has been released in VS Code Insiderson-testplanperfterminalGeneral terminal issues that don't fall under another label
Milestone
Description
As of around a year ago node-pty is launched directly from the renderer process, while this does mean ctrl+c is responsive it has several downsides:
- node-pty crashes will take down the entire window (Often getting full window hangs #71966, Closing integrated terminal causes window to crash with C++ assertion error #71789, Crashes when quickly press ctrl+` twice #74181)
- Data events from node-pty seems to be blocked by the event loop, I suspect this is main the reason conpty is slow, it may also be slowing down non-Windows data flow too
- The remote case the connection can get overwhelmed by fast producing programs.
- node-pty can freeze the window when a busy loop is run in the terminal Freeze when huge data in terminal #106391
My proposal for these problems:
- Reintroduce terminalProcess to host node-pty, calling it nodePtyHostProcess is probably a better name, this protects the extension host and renderer from crashes
- Batch data events inside nodePtyHostProcess (Experiment with buffering the pty data to improve performance #54093), reducing the amount of total events in favor of larger ones
- Introduce a flow control mechanism which ensures the pty does not get too far ahead of xterm.js. This is a little more tricky for the remote case, one idea is to send an ack every x bytes from the renderer and nodePtyHostProcess will pause if it hasn't received the yth last ack (x and y need to be experimented with and may depend on latency) (related custom flow control and discard limit xtermjs/xterm.js#2122, flow control handling node-pty#304)
Reacted by SupinePandora43, Johannes Schickling, Kalyan CHAKRAVARTHI, Alexander, heartacker, Andrei Alecu, Soheil Alizadeh, Yukai Huang, Nicolas HENRY and Andrii Oriekhov
Metadata
Metadata
Labels
feature-requestRequest for new features or functionalityfreeze-slow-crash-leakVS Code crashing, performance, freeze and memory leak issuesinsiders-releasedPatch has been released in VS Code Insiderson-testplanperfterminalGeneral terminal issues that don't fall under another label
Activity
reinux commentedon Jul 3, 2019
Tyriar commentedon Jul 3, 2019
Tyriar commentedon Jul 13, 2019
Commit that moved the process into renderer: 35cee02
Tyriar commentedon Sep 17, 2019
Commit that converted to use amd ed9cdf5
Tyriar commentedon Sep 18, 2019
Did some exploration into this.
How terminal processes are launched currently
Issues:
Using just the ext host
Issues:
yescommand (flow control is eventual solution to this)Prototype: #81106
Moving the processes out of proc, this is how it used to be (before ext host processes)
Issues:
Proposed solution
[1] Uses ext host socket-based message protocol
[2] The terminal services own the host process and establish the connection
Prototype: #81105
Note that this could be split into 2 stages:
ChildProcess.sendand add flow controlArrayBuffersOn flow control
We recently exposed a callback on xterm's write which fires when the data is parsed. This will make flow control much easier that the earlier proposals I talked about. For example we could provide a callback for event nth write and send messages over to TerminalPtyHostProcess to indicate where the renderer is at in parsing the data.
Host conout socket in a worker
Host conout socket in a worker
Tyriar commentedon Jun 11, 2020
I did an exploration into moving node-pty into the main process (#99897) and it worked pretty well. It's just a prototype and falls over when it comes to pty lifecycle management but it seems like it would be quite easy to tweak it to restore terminals across reloads #20013 if it lived in the main process (as the prototype shows). Another benefit is it speeds up the terminal output significantly,
treerunning in the same directly was several times faster due to event loop being freed up, I expect this to also happen when we get microsoft/node-pty#415 in, even when node-pty is hosted in the renderer.My plan is to eventually move node-pty into a process that's forked from the main process and then establishing a direct socket connection for the terminal if possible to the window so we keep pretty much everything of the main process except for the setting up of the connection.
The branch in action with node-pty hosted on the main process and (the hacky) reload persistence:
tmandry commentedon Jul 29, 2020
Restoring the actual terminal session would be great, but restoring the shell layout with current directory and scrollback saved would give 99% of the benefits for me.
Tyriar commentedon Jan 5, 2021
I split the flow control and event batching portion of this into #113827
Create pty service main <-> renderer channel
Tyriar commentedon Feb 11, 2021
Update:
#116373 will be merged soon which will:
I'll close this issue when the above gets merged and defer the following to more targeted issues:
Tyriar commentedon Feb 18, 2021
This is what the process architecture ended up looking like:
PtyService on the pty host process is what creates the terminal processes