From 1045b984c4434188f77799d0f2bd04845c0b9cb7 Mon Sep 17 00:00:00 2001 From: Elazar Gershuni Date: Sun, 4 Aug 2024 17:06:19 +0300 Subject: [PATCH] snapshot twice after each step --- checkpoint/persist.py | 4 ++-- save_snapshot.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/checkpoint/persist.py b/checkpoint/persist.py index 66ae70e..81a5b66 100644 --- a/checkpoint/persist.py +++ b/checkpoint/persist.py @@ -207,9 +207,9 @@ def __init__(self, tag: str) -> None: def commit(self) -> None: self.i += 1 - if self.i % self.step == 0: + if self.i % self.step in [0, 1]: # send commend to save_snapshot server to take snapshot - self.socket.send(struct.pack("Q", self.value)) + self.socket.send(struct.pack("Q", self.i, self.value)) # wait for snapshot to start, and continue after it's done self.socket.recv(256) diff --git a/save_snapshot.py b/save_snapshot.py index aa30d15..2f31517 100644 --- a/save_snapshot.py +++ b/save_snapshot.py @@ -126,7 +126,7 @@ async def relay_qmp_dumps(qmp_port: int, server: Server) -> None: for index in server: async with vm.pause(server.sleep_duration_ms): current_next_file = f"{folder}/{index}.b.dump" - next_prev_file = f"{folder}/{index + persist.read_step()}.a.dump" + next_prev_file = f"{folder}/{index + 1}.a.dump" await vm.dump(current_next_file) os.link(current_next_file, next_prev_file) p: Future[int] = executor.submit(count_diff, folder, index)