Skip to content
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

use notebook serializer for IW model #171283

Merged
merged 7 commits into from
Jan 23, 2023

Conversation

amunger
Copy link
Contributor

@amunger amunger commented Jan 13, 2023

Use a file Provider for the interactive window so that the notebook serializer is used for the notebook model.
The IW file provider will drop any write operations and return an empty buffer for any read.
This way we will rely only on the backup provider to store the file data similar to an untitled file, but it won't request to save the file on close or appear dirty.

Copy link
Collaborator

@mjbvz mjbvz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall the approach looks good to me but also run the FS changes by Ben to make sure this won't cause issues with editor state / backups

Copy link
Member

@rebornix rebornix left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good to me in overall. The only thing we want to double check how IW restore works with different settings (auto save on/off) as we are faking FS/dirty-state.

@amunger amunger requested a review from bpasero January 17, 2023 20:49
@amunger amunger force-pushed the aamunger/IWNotebookSerializer branch from dc66610 to 3f8f39d Compare January 17, 2023 22:51
@amunger amunger marked this pull request as ready for review January 17, 2023 22:52
@vscodenpa vscodenpa added this to the January 2023 milestone Jan 17, 2023
Copy link
Member

@bpasero bpasero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not entirely sure why the no-op filesystem provider is needed to begin with, but instead of implementing this yourself, why not use the InMemoryFileSystemProvider we already have:

export class InMemoryFileSystemProvider extends Disposable implements IFileSystemProviderWithFileReadWriteCapability {

@amunger
Copy link
Contributor Author

amunger commented Jan 18, 2023

I am not entirely sure why the no-op filesystem provider is needed to begin with, but instead of implementing this yourself, why not use the InMemoryFileSystemProvider we already have

There are write operations that occur for auto-save, so it just feels like we would be unnecessarily duplicating the memory usage since it's already stored in the back-up provider. On the other hand, that provider would likely be a better fit for the intended model, so I'm fine with using it if that extra memory usage isn't a concern.

@amunger amunger force-pushed the aamunger/IWNotebookSerializer branch from 9738ba8 to c18791b Compare January 18, 2023 17:56
@amunger
Copy link
Contributor Author

amunger commented Jan 18, 2023

After discussing with @bpasero, dropping all writes is preferrable to storing the data we don't actually need in an in-memory file provider


public async rename(_from: URI, _to: URI, _opts: IFileOverwriteOptions): Promise<void> { }

public async close?(_fd: number): Promise<void> { }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a bit weird to have the ? even though you implement the method.


public constructor(private disposableFactory: () => IDisposable = () => Disposable.None) { }

public async readFile(_resource: URI): Promise<Uint8Array> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fyi you can remove the public keyword, this will make the method public by default.

import { URI } from 'vs/base/common/uri';
import { FileSystemProviderCapabilities, FileType, IFileChange, IFileDeleteOptions, IFileOpenOptions, IFileOverwriteOptions, IFileSystemProvider, IStat, IWatchOptions } from 'vs/platform/files/common/files';

export class InteractiveWindowFileSystem implements IFileSystemProvider {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can reduce the complexity of this class by extending the InMemoryFileSystemProvider and simply overriding the methods that write to the memory by skipping the write. This will make this a very slim class in the end.

Copy link
Member

@bpasero bpasero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some comments how to further simplify this. I still do not understand why we need this, but I trust the judgment, since additional discussions seem to have happened.

@bpasero bpasero self-requested a review January 20, 2023 09:51
bpasero
bpasero previously approved these changes Jan 20, 2023
@amunger amunger mentioned this pull request Jan 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants