-
Notifications
You must be signed in to change notification settings - Fork 269
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
feat(event cache): automatically shrink a room's linked chunk when all subscribers are gone #4703
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4703 +/- ##
==========================================
- Coverage 85.94% 85.94% -0.01%
==========================================
Files 290 290
Lines 33892 33942 +50
==========================================
+ Hits 29130 29170 +40
- Misses 4762 4772 +10 ☔ View full report in Codecov by Sentry. |
// I hear you from the future: "but, spawning a detached task in a drop | ||
// implementation is real bad! Maybe there will be multiple shrinks | ||
// happening at the same time, and that's bad!". However, this can't | ||
// happen, because the whole `state` variable is guarded by a fair lock, | ||
// which will run queries in the order they happen. Should be fine™. |
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.
You forgot to explain why you need to spawn
here. It's because drop
cannot be async, and you're doing async operations.
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.
Yep, introduced a mechanism with one (1) task listening forever in the event cache, that should be more sound.
291665b
to
dcf80a6
Compare
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.
Excellent :-]. Thank you!
…isteners are left
4674ba3
to
c78fc0f
Compare
On top of #4694.
Every subscriber to a
RoomEventCache
now gets an atomic counter of the number of listeners to updates to this room. When the count reaches 0, the listener will notify a task (living at theEventCache
level, to avoid having one task per room) that the room's linked chunk may be shrunk, if the number of listeners is still 0.Part of #3280.