Zannick / logic-graph

Tools for video game logic representation and analysis, particularly routing and beatability checks for speedruns and randomizers.
MIT License
3 stars 0 forks source link

Allow program to resume #141

Open Zannick opened 7 months ago

Zannick commented 7 months ago

As the graph is built out, a lot more can happen during runs, and restarting with tweaks to the search algorithm, queue, or whatever get more painful as we retrod ground we've already covered. Much of the work is reusable--states always lead to the same states, so there ought to be a way to resume where we left off.

  1. Interrupt: We could direct the program to stop and save its state (intercept ctrl-c for example). Mainly what we need is to save the contents of the heap, so that when we resume we can recreate it. The queue and state dbs are fine as-is (as long as they are fully written to disk, which probably requires enabling WAL or having some other flush function).
  2. Crash: If we can't save the heap, we could try to recreate it by scanning the state db: any state with no next entry has not been done, and if that state is not in the queue db, then it must go in the heap. Alternatively, insert such a state into the queue db, and then create a heap by retrieving from the queue db. This would require WAL enabled as well.

Any changes to the graph would require restarting from scratch. We could add a hash or an id of the build state and save that as a db global or something. If it doesn't match the binary, then we exit with an error (for example, telling us to run with a commandline flag to clean the db directory).

Zannick commented 7 months ago

As a side note, profile-guided optimization doesn't seem to record data unless the program exits naturally.