Skip to content

Instantly share code, notes, and snippets.

@addyosmani
Last active October 8, 2015 13:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save addyosmani/cee1ac65263cc7134711 to your computer and use it in GitHub Desktop.
Save addyosmani/cee1ac65263cc7134711 to your computer and use it in GitHub Desktop.
save/restore state

tl;dr: no / it's quite hard :'(

Afaik, it's incredibly difficult to restore a highly multi-threaded system to a set state in time - doing so is non-trivial, but also comes with a heavy cost as quite a few different systems need to be in a relatively stable/safe state so you know what to save. For V8, saving state doesn't guarantee that it's possible to gather all of the information necessary to get you back to where you were in a random point in time given the various execution contexts your code is likely running in. You also need to factor in somehow serializing the different contexts in which your closures and other constructs exist in which is again not straight-forward.

For example, we might not be able to traverse the heap at that point, there may be threads that are still locked, not fully-initialized objects and so on. So at best you would be capturing an incomplete state of the world which may not scale when trying to restore the state of something quite complex. If it were possible to save state, you would have a tricky time restoring it - address space layout randomization (ASLR), many different threads running and so forth.

@remy
Copy link

remy commented Oct 8, 2015

Damn.

sad-cat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment