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

Improve memory use #1805

Closed
matrixbot opened this issue Nov 1, 2024 · 7 comments
Closed

Improve memory use #1805

matrixbot opened this issue Nov 1, 2024 · 7 comments

Comments

@matrixbot
Copy link
Collaborator

This issue was originally created by @ptman at matrix-org/dendrite#1805.

Description:

Dendrite can use a lot of RAM at times and this can result in it getting killed by the oom-killer.

Keywords: ram, memory, oom, resource use, efficiency, killed

@matrixbot
Copy link
Collaborator Author

This comment was originally posted by @ptman at matrix-org/dendrite#1805 (comment).

#1804 could improve this a lot

@matrixbot
Copy link
Collaborator Author

This comment was originally posted by @ptman at matrix-org/dendrite#1805 (comment).

Caching helps a lot in synapse matrix-org/dendrite#1102

@matrixbot
Copy link
Collaborator Author

This comment was originally posted by @kegsay at matrix-org/dendrite#1805 (comment).

Caching bloats baseline memory, it doesn't help it. It helps reduce CPU cycles.

There are several problems which can cause Dendrite to gobble up memory:

  • complicated state resolution. State resolution looks at historical state as well as the current state so older rooms or rooms with lots of membership churn will reduce performance because all those events need to be extracted from the database.
  • resolving state with lots of prev_events. If a room has a lot of servers and they constantly fork the room, when the forks get merged we need to do state resolution. Even small rooms (with lots of forks) can reduce performance due to needing to extract the events multiple times. We can probably improve this with an event cache so we can have pointers to the same structure.

An "easy" fix to all this is to not federate, as all these issues only appear once you start doing state resolution which only happens when servers disagree or need to work out the room state.

@matrixbot
Copy link
Collaborator Author

This comment was originally posted by @ptman at matrix-org/dendrite#1805 (comment).

Yes, caching uses more memory. But counter-intuitively it does sometimes help with synapse, as the cached result uses less memory than the process of re-calculating the value.

@matrixbot
Copy link
Collaborator Author

This comment was originally posted by @neilalexander at matrix-org/dendrite#1805 (comment).

It would be interesting to get some feedback on how much recent changes have helped here. Version 0.4.0 specifically contains some pretty huge improvements on memory usage, especially when dealing with incoming federation events, calculating memberships and running state resolution, so hopefully it is noticeable.

@matrixbot
Copy link
Collaborator Author

This comment was originally posted by @neilalexander at matrix-org/dendrite#1805 (comment).

@ptman I'd be curious to know if you think this is still a problem, especially given recent optimisations in v0.6.x. There are also additional things that have been merged onto main today that should help even more (#2226, matrix-org/gomatrixserverlib#292). I'd like to close this if it's no longer a noticeable issue.

@matrixbot
Copy link
Collaborator Author

This comment was originally posted by @ptman at matrix-org/dendrite#1805 (comment).

Sorry, I lost my dendrite installation. I'll have to deploy a new one at some point when I have a chance. I'll close this for now.

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

No branches or pull requests

1 participant