Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

Periodically save state and store in indexedDB - #10605

Merged
kuychaco merged 49 commits into
masterfrom
ku-crash-recovery
Feb 16, 2016
Merged

kuychaco merged 49 commits into
masterfrom
ku-crash-recovery

Conversation

@kuychaco

Copy link
Copy Markdown
Contributor

Fixes atom/atom#4161

  • separate serialization from package deactivation
  • extract serialization logic from unloadEditorWindow
  • fix package manager tests
  • save state asynchronously on keydown and mousedown, write tests
  • get rid of AtomEnvironment state instance variable
  • fix AtomEnvironment tests
  • profile serialization time for various environment states
  • store state in IndexedDB
  • add command-line flag to clear indexedDB object store

Comment thread spec/atom-environment-spec.coffee Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Spy not working as expected and causing test to fail (you can see in the console that it is getting called):

screen shot 2016-01-27 at 11 18 09 am

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Figured out this was an issue with binding saveStateSync before spying on it

@jeancroy

Copy link
Copy Markdown
Contributor

Is this saved to .atom/storage ?
On the forum, when atom crash on startup, deleting the storage folder is a standard debug step.
Maybe there's an interest in discarding most of the state but restoring unsaved file content.

@kuychaco kuychaco changed the title Implement crash recovery Periodically save workspace state Jan 27, 2016
@kuychaco kuychaco changed the title Periodically save workspace state (WIP) Periodically save workspace state Jan 28, 2016
@kuychaco

Copy link
Copy Markdown
Contributor Author

@jeancroy thanks for your comment. To answer your question - yes, the atom environment state is saved to .atom/storage. That said, I'm going to create an unsaved text buffers store that will be located elsewhere (possibly using IndexedDB). So in the event of a crash and deletion of the storage folder, your unsaved buffers will be preserved.

The unsaved buffer store will be a part of a separate pull request. I've updated the title of this one to be more specific as to what aspect of crash recovery will be addressed here.

@maxbrunsfeld

Copy link
Copy Markdown
Contributor

This is looking good! How long does saveStateSync on average? Does it vary much depending on how many open buffers you have?

@YurySolovyov

Copy link
Copy Markdown

I wonder if we can use requestIdleCallback here once we have chrome 47+

@maxbrunsfeld

Copy link
Copy Markdown
Contributor

I wonder if we can use requestIdleCallback here once we have chrome 47+

Yeah, we should start using that, as soon as #9627 lands

Comment thread src/storage-folder.coffee Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this should be called store... the convention in Node is to have async be implied and only mention sync vs async on a sync alternative.

@kuychaco

kuychaco commented Feb 2, 2016

Copy link
Copy Markdown
Contributor Author

Did some profiling. Here are durations for saveState (synchronous serialization, and async writing to disk):

State Time
20 tabs opened 2 ms
large unsaved buffer (jquery, 10K lines)* 11 ms

*Marker Layer serialization took 8.3 ms

20 tabs open:
screen shot 2016-02-01 at 5 58 09 pm

large unsaved buffer (jquery, 10K lines)
screen shot 2016-02-01 at 5 16 20 pm

Comment thread src/atom-environment.coffee Outdated

@packages.loadPackages()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔥 this trailing whitespace

@nathansobo

Copy link
Copy Markdown
Contributor

Very solid work @kuychaco. I did a pretty quick scan and things look good to me. Are you thinking of adding the --clear-workspace-state flag before merging?

@kuychaco

Copy link
Copy Markdown
Contributor Author

@nathansobo thanks for the review! I think I will add the command-line flag before merging. Hope to get that done tonight.

kuychaco added a commit that referenced this pull request Feb 16, 2016
(WIP) Periodically save state and store in indexedDB
@kuychaco
kuychaco merged commit cfab689 into master Feb 16, 2016
@kuychaco
kuychaco deleted the ku-crash-recovery branch February 16, 2016 19:58
@benogle

benogle commented Feb 16, 2016

Copy link
Copy Markdown
Contributor

💥

@maxbrunsfeld maxbrunsfeld changed the title (WIP) Periodically save state and store in indexedDB Periodically save state and store in indexedDB Feb 16, 2016
@as-cii as-cii mentioned this pull request Mar 4, 2016
1 task done
@jeancroy

Copy link
Copy Markdown
Contributor

Hi @kuychaco

Is there mechanism to migrate state data from previous format to the new IndexedDB format ?
Here's one thread where a beta user think he lost all his state data on upgrade, but it was there, just ignored/not loaded.

https://discuss.atom.io/t/upgrading-to-1-7-0-beta0-blew-away-my-session-any-way-to-restore/26918
It could be interesting to avoid a widespread fear of data loss.

@iolsen

iolsen commented Mar 22, 2016

Copy link
Copy Markdown
Contributor

cc @as-cii ☝️

@nathansobo

Copy link
Copy Markdown
Contributor

Talked with @as-cii and he's planning on falling back to reading the state out of ~/.atom if it is present and there's nothing in the database. Thanks for the heads-up @jeancroy. People care more about their session state than I realized.

@mehcode

mehcode commented Mar 22, 2016

Copy link
Copy Markdown
Contributor

Great to hear there is a fallback in the works. 👍


[...] People care more about their session state than I realized.

People (me) have even written a package to list / inspect / make use of session state. It really is a nice feature of Atom.

@miguelbarrio miguelbarrio left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Feature Request: add crash restore

10 participants