You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Backup file system provider can not do buffered write #193151
Does this issue occur when all extensions are disabled?: Yes/No
VS Code Version: 1.83-Insiders
OS Version: macOS
I was verifying #192970 and found that large file piece tree buffers are still merged before write. Turns out that backup is always doing doWriteUnbuffered since it's using FileUserDataProvider, which doesn't have FileOpenReadWriteClose capability so it always runs
One interesting behavior I found is sometimes backup happens right after I press cmd+s to save, maybe the delayed backup kicks in right before I save, but it feels weird to have both a backup and save operation at the same time.
Good catch, but I think this is simply something that was forgotten when introducing the file user data provider. Since the underlying disk file system provider supports this, I see no reason why the file user data provider could not support this.
I think we may be fine to bring back that capability. The file service is already optimising the calls to the provider in a way that writeFile is being called when the buffer is not too large (3*64kb I think):
Sandeep Somavarapu (@sandy081) yes, that is what the IFileService will probe for before deciding which method to use. Since yours does not declare it, all writes are without streaming.
I experimented adding the FileOpenReadWriteClose capability to the FileUserDataProvider#193228, with this backup streams again and no longer blocks the UI. Feel free to discard my PR if it's in the wrong direction
I wonder if a better approach for this would be to drop the FileUserDataProvider and simply expose a method on IFileService to set options for certain paths.
Basically this method would call into IFileService instead of requiring to subclass the disk file system provider:
Sandeep Somavarapu (@sandy081) I would not suggest to change anything with regards to URI or scheme, just simply add a way on the IFileService to enforce custom options when writing for a set of Uri. Its a bit of a hack, but I find the custom file system provider to cause more issues. I would assume you can drop it then.
I am wondering it is not straight forward to use disk FSP without changing the scheme. The main purpose of vscode-userdata fsp is to handle the scheme, for eg., watching on user data scheme and getting change events on the same scheme. We should also adopt the disk FSP not to call uri.fsPath directly which I saw using it here
Sandeep Somavarapu (@sandy081) I went with a slightly different approach: since the file user data provider is used in many contexts, it makes more sense to keep the decision about which resources should get atomic read/write inside the provider. As such, I added new methods to enforce atomic read, write or delete: #193228
This bug has been fixed in the latest release of VS Code Insiders!
Peng Lyu (@rebornix), you can help us out by commenting /verified if things are now working as expected.
If things still don't seem right, please ensure you're on version c72447e of Insiders (today's or later - you can use Help: About in the command palette to check), and leave a comment letting us know what isn't working as expected.
Activity
rebornix commentedon Sep 15, 2023
One interesting behavior I found is sometimes backup happens right after I press cmd+s to save, maybe the delayed backup kicks in right before I save, but it feels weird to have both a backup and save operation at the same time.
bpasero commentedon Sep 15, 2023
Good catch, but I think this is simply something that was forgotten when introducing the file user data provider. Since the underlying disk file system provider supports this, I see no reason why the file user data provider could not support this.
Sandeep Somavarapu (@sandy081) can you check?
bpasero commentedon Sep 15, 2023
Looks like this was an explicit decision in 87bf1d8#diff-28073e52c2a7e44ac456dfb32c4f0794985cb4a4bcc7c0d99a033e8224fff52cR25 and probably done to enforce atomic writes.
I think we may be fine to bring back that capability. The file service is already optimising the calls to the provider in a way that
writeFileis being called when the buffer is not too large (3*64kb I think):vscode/src/vs/platform/files/common/fileService.ts
Lines 372 to 390 in 2553649
On top of that: if any component comes with a buffer for writing, we never stream:
vscode/src/vs/workbench/services/textfile/browser/textFileService.ts
Lines 267 to 275 in 2553649
Which I would assume is the case for all our settings when written to programmatically.
sandy081 commentedon Sep 15, 2023
Benjamin Pasero (@bpasero) Does it also need
FileUserDataProviderto supportFileSystemProviderCapabilities.FileOpenReadWriteClose?bpasero commentedon Sep 15, 2023
Sandeep Somavarapu (@sandy081) yes, that is what the
IFileServicewill probe for before deciding which method to use. Since yours does not declare it, all writes are without streaming.Fix #193151. Add IFileSystemProviderWithOpenReadWriteCloseCapability …
rebornix commentedon Sep 15, 2023
I experimented adding the
FileOpenReadWriteClosecapability to theFileUserDataProvider#193228, with this backup streams again and no longer blocks the UI. Feel free to discard my PR if it's in the wrong directionbpasero commentedon Sep 18, 2023
I wonder if a better approach for this would be to drop the
FileUserDataProviderand simply expose a method onIFileServiceto set options for certain paths.Basically this method would call into
IFileServiceinstead of requiring to subclass the disk file system provider:vscode/src/vs/platform/userData/common/fileUserDataProvider.ts
Lines 54 to 62 in fa99dac
sandy081 commentedon Sep 18, 2023
I liked that. Does it mean we should not use
vscode-userdatascheme in Desktop?bpasero commentedon Sep 18, 2023
Sandeep Somavarapu (@sandy081) I would not suggest to change anything with regards to
URIorscheme, just simply add a way on theIFileServiceto enforce custom options when writing for a set ofUri. Its a bit of a hack, but I find the custom file system provider to cause more issues. I would assume you can drop it then.sandy081 commentedon Sep 18, 2023
I am wondering it is not straight forward to use disk FSP without changing the scheme. The main purpose of vscode-userdata fsp is to handle the scheme, for eg., watching on user data scheme and getting change events on the same scheme. We should also adopt the disk FSP not to call
uri.fsPathdirectly which I saw using it herevscode/src/vs/platform/files/common/diskFileSystemProvider.ts
Lines 217 to 219 in d8e6919
bpasero commentedon Sep 18, 2023
Sandeep Somavarapu (@sandy081) how about this then:
vscode-userdatascheme as we do today ✅fileUserDataProvideras we do today ✅IFileServiceto enforce atomic writes with the knowledge we have from 3b60c12I think then we get the best of all worlds:
fsPathhandlingIFileServicebased on a whithlist and the new APIsandy081 commentedon Sep 19, 2023
Sounds good 👍
bpasero commentedon Sep 20, 2023
Sandeep Somavarapu (@sandy081) I went with a slightly different approach: since the file user data provider is used in many contexts, it makes more sense to keep the decision about which resources should get atomic read/write inside the provider. As such, I added new methods to enforce atomic read, write or delete: #193228
vscodenpa commentedon Sep 22, 2023
This bug has been fixed in the latest release of VS Code Insiders!
Peng Lyu (@rebornix), you can help us out by commenting
/verifiedif things are now working as expected.If things still don't seem right, please ensure you're on version c72447e of Insiders (today's or later - you can use
Help: Aboutin the command palette to check), and leave a comment letting us know what isn't working as expected.Happy Coding!