Skip to content
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

fix(event cache): give looser parameters for the deduplicator's bloom filters #4231

Merged
merged 1 commit into from
Nov 7, 2024

Conversation

bnjbvr
Copy link
Member

@bnjbvr bnjbvr commented Nov 7, 2024

The previous values would lead to super large memory allocations, as observed with valgrind --tool=massive on the tiny test added in this commit:

  • for 400 rooms each having 100 events, this led to 540MB of allocations.
  • for 1000 rooms each having 100 events, this led to 1.5GB of allocations.

This is not acceptable for any kind of devices, especially for mobile devices which may be more constrained on memory. The bloom filter is an optimisation to avoid going through events in the room's event list, so it shouldn't cause a big toll like that; instead, we can reduce the parameters values given when creating the filters.

With the given parameters, 1000 rooms each having 100 events leads to 1.2MB of allocations.

@bnjbvr bnjbvr requested a review from a team as a code owner November 7, 2024 11:21
@bnjbvr bnjbvr requested review from jmartinesp and removed request for a team November 7, 2024 11:21
Copy link
Contributor

@jmartinesp jmartinesp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a comment about the test.

Copy link
Contributor

@poljar poljar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a question and a nit. Looks good, thanks for investigating.

crates/matrix-sdk/src/event_cache/deduplicator.rs Outdated Show resolved Hide resolved
Copy link

codecov bot commented Nov 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.82%. Comparing base (6528717) to head (8d49a90).
Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4231   +/-   ##
=======================================
  Coverage   84.82%   84.82%           
=======================================
  Files         273      273           
  Lines       29519    29519           
=======================================
  Hits        25039    25039           
  Misses       4480     4480           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

… filters

The previous values would lead to super large memory allocations, as
observed with `valgrind --tool=massive` on the tiny test added in this
commit:

- for 400 rooms each having 100 events, this led to 540MB of
allocations.
- for 1000 rooms each having 100 events, this led to 1.5GB of
allocations.

This is not acceptable for any kind of devices, especially for mobile
devices which may be more constrained on memory. The bloom filter is an
optimisation to avoid going through events in the room's event list, so
it shouldn't cause a big toll like that; instead, we can reduce the
parameters values given when creating the filters.

With the given parameters, 1000 rooms each having 100 events leads to
1.2MB of allocations.
@bnjbvr bnjbvr force-pushed the bnjbvr/lower-bloom-filter-heuristics branch from 962c18c to 8d49a90 Compare November 7, 2024 11:44
@bnjbvr bnjbvr enabled auto-merge (rebase) November 7, 2024 11:44
@bnjbvr bnjbvr merged commit bab6761 into main Nov 7, 2024
40 checks passed
@bnjbvr bnjbvr deleted the bnjbvr/lower-bloom-filter-heuristics branch November 7, 2024 11:59
@Hywan
Copy link
Member

Hywan commented Nov 11, 2024

Oh, nice, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants