-
-
Notifications
You must be signed in to change notification settings - Fork 655
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
/sync performance slow since v0.10.0 #2777
Comments
I can confirm. With weechat-matrix I am no longer able to login for this reason. |
How are your database connections configured? Are you using the |
I'm using one global database connection pool with following config:
|
With a total connection count of 10 shared across the entirety of Dendrite, I'm not at all surprised to hear things are slow. Are you using such a low limit for a specific reason? |
I did an experiment and set Server I am running, does not get a lot of traffic, and I'm almost alone running queries, so available connections do not seem to be exhausted. Looking from the metrics that PostgreSQL reports, I can tell that Dendrite uses 5 connections or less. |
After increasing per component connections to 100, I was able to login again: Mic92/dotfiles@9f6de28 |
I created a database dump, imported data to a new database and enabled statement logging in Postgres for that database only. Then I ran docker container with version 0.9.1 and 0.10.3 (latest). Here's what I found: matrixdotorg/dendrite-monolith:v0.9.1
With single HTTP request, Dendrite made 858 database queries, top 10 being:
matrixdotorg/dendrite-monolith:v0.10.3 (latest)
With single HTTP request, Dendrite made 3504 database queries, top 10 being:
EDIT. I additionally tested with database (from same dump) and Dendrite container (0.10.3) running on the same host and noticed that HTTP request times were quite OK (around 0.6 sec). If Dendrite and PostgreSQL are running on different hosts, then network latency becomes an issue and request times are as slow as I've described above. Any thoughts, any suggestions what to try next? |
This optimizes history visibility checks by (mostly) avoiding database hits. Possibly solves #2777 Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com>
@raidokaldma mind giving |
Edit: I removed my previous response, which was incorrect Since last time I had removed previous database and recreated a new one, so response times are not 1:1 comparable with previous comments, but regardless here is what I found: I had matrixdotorg/dendrite-monolith:v0.10.4 running, so I did a measurement to get the baseline response time:
Then I ran matrixdotorg/dendrite-monolith:v0.10.6 which is the latest right now, and ran the same request again:
Improvement is noticable indeed, but it is still slower compared to what I had before 0.10.0. That being said, I'm doing other sorts of optimization in my JS code (matrix-js-sdk) to overcome the slowness, making use of And also big thank you for investing time and shipping improvements. |
This comment was marked as off-topic.
This comment was marked as off-topic.
@raidokaldma thank you very much for your detailed and comprehensive reporting. I have a few follow-up questions:
Thanks! |
Hey, thanks for dedicating time to the issue. I still have my database dump, and here's a summary of what my database contains:
|
@raidokaldma not yet merged, but PR #2961 should significantly reduce the queries and be much more performant. Your filter might cause problems, because you're getting the whole state for each room, enabling lazy loading will improve the response time drastically with that PR. |
Should fix the following issues or make a lot less worse when using Postgres: The main issue behind #2911: The client gives up after a certain time, causing a cascade of context errors, because the response couldn't be built up fast enough. This mostly happens on accounts with many rooms, due to the inefficient way we're getting recent events and current state For #2777: The queries for getting the membership events for history visibility were being executed for each room (I think 185?), resulting in a whooping 2k queries for membership events. (Getting the statesnapshot -> block nids -> actual wanted membership event) Both should now be better by: - Using a LATERAL join to get all recent events for all joined rooms in one go (TODO: maybe do the same for room summary and current state etc) - If we're lazy loading on initial syncs, we're now not getting the whole current state, just to drop the majority of it because we're lazy loading members - we add a filter to exclude membership events on the first call to `CurrentState`. - Using an optimized query to get the membership events needed to calculate history visibility --------- Co-authored-by: kegsay <kegan@matrix.org>
I finally found time to test latest changes. In my case initial sync on version v0.10.8 took 5s, with v0.11.1 same request responds in 0.7s. The difference is noticeable. Thank you @S7evinK! Feel free to close the issue if no further work on the issue is planned. |
We will be adding in more comprehensive profiling via |
Background information
Description
I'm running Dendrite in Docker and noticed a huge difference in performance when doing initial sync when switching from v0.9.9 to v0.10.0 or v0.10.1
Response times in my server:
With docker image matrixdotorg/dendrite-monolith:v0.9.9
With docker image matrixdotorg/dendrite-monolith:v0.10.1
The text was updated successfully, but these errors were encountered: