-
-
Notifications
You must be signed in to change notification settings - Fork 458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf: query fewer historical messages on reconnects #5001
perf: query fewer historical messages on reconnects #5001
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
The service at |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hope it's not too many changes, I was just trying to be thorough in all the places that I thought would require changes
const auto duration = std::ceil((now - this->disconnectedAt_) / 1000.0); | ||
limit = std::min(static_cast<int>(duration) * 10, | ||
getSettings()->twitchMessageHistoryLimit.getValue()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const auto duration = std::ceil((now - this->disconnectedAt_) / 1000.0); | |
limit = std::min(static_cast<int>(duration) * 10, | |
getSettings()->twitchMessageHistoryLimit.getValue()); | |
const auto disconnectDuration = now - this->disconnectedAt_; | |
const auto disconnectDurationSeconds = std::chrono::duration_cast<std::chrono::seconds>(disconnectDuration).count(); | |
// At least 10 messages, even on very short reconnects that are < 1 full second | |
limit = std::min(std::max(disconnectDurationSeconds, 1) * 10, limit); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we actually always want to round up to the nearest int (i.e., treat 999ms as 1s, treat 1100ms as 2s - in the 1100ms case, 10 messages could occur at t=0 and 10 at t=1100)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
Co-authored-by: Ruben Anders <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
…meter default values
Co-authored-by: Ruben Anders <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me - can you take a look at the changes I've made to see if they make sense @iProdigy?
After that, I'll go ahead and merge this in.
Changes look good to me! thank you @pajlada and @RAnders00 |
Co-authored-by: Ruben Anders <[email protected]>
I'm going to merge this in, but one thing I thought about is the use case for when someone puts their computer to sleep with Chatterino running. Will Chatterino only request 10-20 messages upon the computer waking up in this case? |
To be honest we could have skipped the entire ?limit parameter calculation. The before and after parameters do everything for us, and I don't need the ?limit for server performance, filtering by time range without limit or with a high limit is just as efficient, it's all about the number of messages returned. |
I made #5009 to track any follow-up changes related to sleep |
even if we omitted |
Implements smaller
?limit
on recent message query upon reconnects, as suggested in #4989Note:
system_clock
is used instead of a strictly monotonic clock in anticipation of thesince
query parameter robotty/recent-messages2#286