-
Notifications
You must be signed in to change notification settings - Fork 29.5k
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
Crash when notebook scrolling is on and a lot of output is streamed in #182636
Comments
@rebornix @DonJayamanne are you accepting PRs for this? It looks like, there is no batching of events from the notebook, although you made processing each event more efficient last year. The renderer is calculating the scroll height each time stderr is flushed |
I guess |
@r3m0t thanks for offering help, it would be very great. We might need to carefully design the debouncing to ensure a smooth incremental update experience though. |
I had a look last week, but I found many concerns. It's not just the renderer. Basically, import sys, json
res = []
total_message_length = 0
for i in range(31500):
res.append('{!r} {!r}\n'.format(list(range(10)), i))
message = json.dumps({'event': 'update_output', 'output_id': '01010239032-3210-321-312321321', 'contents': ''.join(res)})
total_message_length += len(message)
print(f'Sending {total_message_length:,.0f} bytes with a final output of {len(message)}')
# Sending 18,556,686,495 bytes with a final output of 1185979 That's really excessive, and there's a lot of work needed in the output renderer as well. Each time it processes all the last 5000 lines for ANSI colors and links, instead of just the new part, and creates new div elements - vscode/extensions/notebook-renderers/src/textHelper.ts Lines 94 to 104 in 143d967
it would make more sense to send incremental content - vscode/src/vs/workbench/contrib/notebook/browser/view/renderers/backLayerWebView.ts Line 1492 in 143d967
Separate issue as it's on the main host side- there is also quadratic behaviour in
Basically, debouncing would require I might be able to send you some small changes to optimize https://github.com/microsoft/vscode/blob/143d9674dd470c8f3d3a5e4b930f5eb1fe9a91d3/extensions/notebook-renderers/src/index.ts , but I don't think performance will be good until you can tackle the above. Or should I just tell my users to go to Terminal 🤣 |
Oh, and I think I'm basically suggesting unpicking #161023 - or optimizing for both cases (append usually but replace when |
We were considering incremental updates to the output here, but decided for a simpler change to fix that issue. As you noted, we look for characters that edit previous outputs and compress the buffer into a single output, which would be very difficult to support if we only sent text to append. We also need to consider 3rd party renderers that would break if we changed the message in such a way. We have a hard limit of 5000 lines for text output in the renderer, so it might make sense to also limit the message sent to help mitigate this issue. |
I don't think third party renderers need to be affected as the escape sequences are already only handled for a few hard coded MIME types. Are there other renderers for these types? Are there other MIME types that need to be handled incrementally? In the Jupyter protocol, you can't incrementally update an output of a MIME type. This can be private API to the built in stream renderers. I do agree |
Thanks for putting this on the iteration plan, can you tag it freeze-crash? I'll leave you with my thoughts which may be useful in implementation, hopefully this doesn't send you down the wrong way!
PS While writing I noticed |
@amunger and I discussed how we can introduce incremental rendering to the stream output renderer and his experiments are looking promising. Here are some perf logs we captured With incremental rendering Every output Without incremental rendering Without incremental update, every update is a "remove" and then "insert" and the "insert" operation is getting bigger, thus the rendering time for each operation is getting longer. Starting from around 2ms, all the way to tens or hundreds of ms |
Does this issue occur when all extensions are disabled?: Yes/No
Version: 1.79.0-insider (user setup)
Commit: 2575777
Date: 2023-05-12T05:21:06.392Z
Electron: 22.5.2
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Windows_NT x64 10.0.19045
Sandboxed: Yes
Steps to Reproduce:
"notebook.output.scrolling": true, "notebook.output.textLineLimit": 30
(this is the default)This works, it's only abou 1 MB of output.
The renderer crashes!
The text was updated successfully, but these errors were encountered: