New edition.
http://code.google.com/p/feos-tas/source/detail?r=582
Now we have lua hash implemented in pcsx. It uses the framebuffer provided by lua loop that co-operates with GPU (also used by dgscreenshot for example).
It was proven, that it never matters what GPU was used to make a state, when you load it, you get the picture you need at proper resolution. It means, we can do all passes with lowres TAS GPU and move to hires antialiasing when capturin, it will look proper. So we can rely on lua hashing pretty much.
If we could keep 2 instances in sync, we won't ever need frequent backup savestates. If framecount of one instance overruns another, it must be set to sleep. Once check instance (eternal) finds the first desync, partol instance (tas) makes a state and freezes. If desync in eternal lasts 15 frames, it loads the state tas instance just created.
If the state was LOADED by app2, that state is reserved. If desync disappeared, both resume running, and at the next desync this state gets replaced somehow.
At the end, we will only have the necessary states. They are to be loaded at capturing. And all that can be done in lua with small expect of OOM.
BUT: we can't control 2 instances with one script. Only through sockets. So, we either keep using sockets, or add some kind of interaction to pcsx, or build the external app to read the returned hashes and framecounts, make and load states, sleep instances. Probably not as hard as it can sound. But some experienced hints are needed.