-
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
Send output item data as VSBuffer #125819
Comments
kinda blocked by #125668 |
@jrieken even the current output data array is chopped off: RandomFractals/vscode-data-table#30 (comment) would be nice to read the whole binary array data from cell output. Are you truncating it for text data display only? |
I looked into this a little since I'd done something similar for webviews. I think there are two potential approaches to optimize Pass the the output data buffers as top level arguments to ipc callsFor any ipc call that deals with an cell output, pass the list of output VSBuffers as top level arguments:
This ensures that they are efficiently serialized by our existing ipc implementation Then for export interface NotebookOutputItemDto {
readonly mime: string;
readonly bufferIndex: number;
} Making this change is sort of a pain because it requires updating a lot of to/from conversation functions to take an array of output buffers Add ipc support for efficiently serializing VSBuffers inside of objectsFirst update export interface NotebookOutputItemDto {
readonly mime: string;
readonly buffer: VSBuffer;
} On its own, this would result in the buffer being very inefficiently serialized. So we'd also need update our IPC implementation to deeply detect and VSBuffers inside of passed in arguments and then serialize them more efficiently This efficiently serialization would likely be similar to what we do for webviews:
I feel this approach is probably better since it not specific to notebooks. However I'm not sure if it would significantly degrade performance for all ipc calls. I believe we already walk objects during serialization/deserialization to handle URIs so it may be ok. We could also make the behavior opt-in and only enable it for specific calls that need it |
I have not looked at what constitutes a VSBuffer. Would it be possible to instead use NodeJS has much better documentation on streams. I assume VSBuffer does some of it. However, I don't like the proposed api above. I'd prefer to see cell outputs and renderers use standard JS APIs for data streaming and piping data to make them easier to test, etc. I liked that current cell output API exposes This goes back to the original discussion on cell data outputs we started here: #123884 (comment) |
Fixes #125819 This PR lets us transfer the notebook output as a VSBuffer instead of as an array of numbers To implement this, I reworked our rpc logic to support serializing VSBuffers inside of objects. Previously rpc calls could only efficiently serialize VSBuffers that appear as top level arguments To support transferring VS Buffers, during serialization we use the `replacer` argument on `JSON.stringify` to extract and replace all buffers in the arguments with special reference objects. During de-serialization, when we encounter one of these reference objects we simply replace it with the corresponding restored buffer. While implementing the new rpc logic, the separation between 'mixed' and 'simple' rpc arguments became less clear. Therefore I decided to try to combine roc calls to use a single arguments format. This simplified the code but I may revisit this to see if I can improve the performance. Right now serialization up 2x slower for large objects (usually it's less than that), while deserialization is about the same as it was previously. I believe the root cause is that we now potentially make two function calls per argument value: one for the outer replacer and one for the inner `JSONStringifyReplacer`.
Fixes #125819 This PR lets us transfer the notebook output as a VSBuffer instead of as an array of numbers To implement this, I reworked our rpc logic to support serializing VSBuffers inside of objects. Previously rpc calls could only efficiently serialize VSBuffers that appear as top level arguments To support transferring VS Buffers, during serialization we use the `replacer` argument on `JSON.stringify` to extract and replace all buffers in the arguments with special reference objects. During de-serialization, when we encounter one of these reference objects we simply replace it with the corresponding restored buffer. While implementing the new rpc logic, the separation between 'mixed' and 'simple' rpc arguments became less clear. Therefore I decided to try to combine roc calls to use a single arguments format. This simplified the code but I may revisit this to see if I can improve the performance. Right now serialization up 2x slower for large objects (usually it's less than that), while deserialization is about the same as it was previously. I believe the root cause is that we now potentially make two function calls per argument value: one for the outer replacer and one for the inner `JSONStringifyReplacer`.
Fixes #125819 This PR lets us transfer the notebook output as a VSBuffer instead of as an array of numbers To implement this, I reworked our rpc logic to support serializing VSBuffers inside of objects. Previously rpc calls could only efficiently serialize VSBuffers that appear as top level arguments To support transferring VS Buffers, during serialization we use the `replacer` argument on `JSON.stringify` to extract and replace all buffers in the arguments with special reference objects. During de-serialization, when we encounter one of these reference objects we simply replace it with the corresponding restored buffer. While implementing the new rpc logic, the separation between 'mixed' and 'simple' rpc arguments became less clear. Therefore I decided to try to combine roc calls to use a single arguments format. This simplified the code but I may revisit this to see if I can improve the performance. Right now serialization up 2x slower for large objects (usually it's less than that), while deserialization is about the same as it was previously. I believe the root cause is that we now potentially make two function calls per argument value: one for the outer replacer and one for the inner `JSONStringifyReplacer`.
Fixes #125819 This PR lets us transfer the notebook output as a VSBuffer instead of as an array of numbers. This significantly reduces the rpc message size when talking about notebook outputs and also speed up serialization and deserialization of notebook outputs. To implement this, I reworked our RPC logic to optionally support serializing VSBuffers inside of objects. Previously RPC calls could only efficiently serialize VSBuffers that appeared as top level arguments
Currently output items send data as number array. That's not ideal and use send things a VSBuffer for which the IPC layer is fast. This is a bigger change because it requires to stop using
IOutputItemDto
fromextHost.protocol.ts
The text was updated successfully, but these errors were encountered: