You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
unread: Use state.messages to optimize updating stream unreads.
Before this commit, when a message was marked as read we'd have to
search through this entire data structure to find where it was so we
could remove it. In fact, even if the message was actually a PM we'd
end up searching through this whole data structure which is entirely
about stream messages, because we didn't use that information.
The same thing was true with the old data structure, before this
series.
Much better would be, when a message in a particular conversation gets
marked as read, to go straight to that particular conversation's part
of the data structure and update that without having to search through
anything else. Do that.
Knowing what conversation the message is in requires looking that
information up in our data structures. Happily we can do that now
(and without an intrusive hack like we've sometimes done in the past):
that was #4437.
This reduces the time spent in this reducer to 7ms in the slowest
sample I've seen, or as little as <1ms (until recently the threshold
of measurement), and the total time spent in dispatch to 110-120ms.
Those compare with 30-50ms reducer / 150-200ms total before this
commit, and with 70ms reducer / 300ms total before the whole series,
using the old data structure. (Based on measuring the same way as
described a few commits ago.) So that's an improvement of about 2.5x,
or 180ms!
The 110-120ms we're still spending, almost all of it now outside the
reducer, still isn't *great*. But it's enough better that I think
further optimization is no longer a top-priority thing for me to work
on; and because the remaining problem isn't inside the reducer where
I've been working and have built up the perf-logging tools to iterate
on, it's beyond the scope of where it's just easy to keep going. So
with this I'm declaring victory on #4438, the task of making this
"unread" model efficient at marking a message as read.
Fixes: #4438
0 commit comments