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

wait for storage backup to finish to start new backup #12064

Merged

Conversation

IanMatthewHuff
Copy link
Member

For #12058

  • Pull request represents a single change (i.e. not fixing disparate/unrelated things in a single PR).
  • Title summarizes what is changing.
  • Has a news entry file (remember to thank yourself!).
  • Appropriate comments and documentation strings in the code.
  • Has sufficient logging.
  • Has telemetry for enhancements.
  • Unit tests & system/integration tests are added/updated.
  • Test plan is updated as appropriate.
  • package-lock.json has been regenerated by running npm install (if dependencies have changed).
  • The wiki is updated with any design decisions/details.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@IanMatthewHuff
Copy link
Member Author

IanMatthewHuff commented May 29, 2020

notebookStorageProvider calls autoSaveNotebookInHotExitFile on a 250ms debounce. But in that function it just does a fire and forget on storage.backup. If saving a big file (the one I was testing with was 70MB) these stack up faster than they can be resolved. So if you trace on the start and end of backup it looks like this if you just type away in a cell for a while, the hard drive is still spinning heavily for a while after finishing typing:

image

Instead of tweaking the debounce it made more sense to me to have the storage only allow for a single backup request to queue in line. Make the responsibility on the storage to not perform unneeded backups that have already been outdated by new incoming backup requests. Code now replaces the current waiting backup request with any new requests that come in. The same approximate amount of typing looks like this now:
image

@IanMatthewHuff IanMatthewHuff changed the title add news and wait for backup to finish to start new one wait for storage backup to finish to start new backup May 29, 2020
@@ -474,6 +474,12 @@ export class NativeEditorStorage implements INotebookStorage {
return this.savedAs.event;
}
private readonly savedAs = new EventEmitter<{ new: Uri; old: Uri }>();

// Keep track of if we are backing up our file already
private backingUp = false;
Copy link

Choose a reason for hiding this comment

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

Another way to do this might be to cancel the previous save (create a merged token source) and debounce a new one every time a new request comes in and the previous isn't finished

Copy link

Choose a reason for hiding this comment

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

But then you might end up with half finished writes

Copy link

Choose a reason for hiding this comment

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

I wonder if part of the problem is we're writing the entire file every time. We could just do updates? That's a lot more complicated though. Probably have to keep a file stream open and seek around to the write spot and stuff.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I thought about the cancel as well. But my fear / worry was what you mentioned about the writes. The big time sink is the file write, and cancelling that halfway seems dicey with a write halfway done.

Copy link
Member Author

Choose a reason for hiding this comment

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

Long term not writing the entire file seems like the right solution. I could open a new issue for that? I think it's a bigger work item. But I'd agree that writing a 70MB file shouldn't happen a few times a second as I type in a markdown cell. With some of these dense plots types I think that it's not too hard to generate pretty big ipynbs.

Copy link

Choose a reason for hiding this comment

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

Yeah the only real solution here would be to not write out the entire contents each time. I'll enter an issue for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants