decrease mem usage (though still linear to replay size)

This commit is contained in:
Roman Trapeznikov 2024-01-08 18:08:07 +03:00
parent e3ef47dfc0
commit 069cd054a0
No known key found for this signature in database
GPG Key ID: 7F4F4115DE048582
2 changed files with 10 additions and 3 deletions

View File

@ -134,8 +134,10 @@ void ClientSessionReplay::FetchMessages() {
// If we have no messages left, read from the file until we get some.
while (commands().empty()) {
{
// Before we read next message, let's save our current state.
// Before we read next message, let's save our current state
// if we didn't that for too long.
unsaved_messages_count_ += 1;
if (unsaved_messages_count_ > 50) {
SessionStream out(nullptr, false);
DumpFullState(&out);
@ -280,7 +282,10 @@ void ClientSessionReplay::OnReset(bool rewind) {
}
}
void ClientSessionReplay::SaveState() { states_.push_back(current_state_); }
void ClientSessionReplay::SaveState() {
unsaved_messages_count_ = 0;
states_.push_back(current_state_);
}
void ClientSessionReplay::RestoreState(millisecs_t to_base_time) {
ScreenMessage("was: " + std::to_string(base_time()) + "ms");

View File

@ -49,6 +49,8 @@ class ClientSessionReplay : public ClientSession,
std::vector<IntermediateState> states_;
IntermediateState current_state_;
int unsaved_messages_count_{};
uint32_t message_fetch_num_{};
bool have_sent_client_message_{};
std::vector<ConnectionToClient*> connections_to_clients_;