-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Improve performance of background update populate_user_directory_process_rooms
#15264
Comments
The main issue (from my understanding) is that it reports based on the number of rooms which are processed, but rooms vary in how "expensive" they are. Maybe using something like That might allow the background update algorithm to process it a bit more reasonably. |
For background: we saw a significant slowdown on This appears to have aligned with some work done by the synapse/synapse/storage/databases/main/user_directory.py Lines 583 to 595 in 335f52d
... which, based on postgres's slow query logs, completed at 21:12 UTC on 2023-03-13, exactly coinciding with the first spike in the above graph.
I'm not convinced that's the main issue. Certainly the updates are quite expensive, but empirically the delete caused a problem too - and it's much harder to break down into small steps. To be determined here:
|
We should use |
Do we think #15316 is enough here or is there more to do? |
I don't know of anything more to do here for now — do we still see trouble on Matrix.org? |
Empirically its doing ~1Hz of room processing on matrix.org, which is going to take months? We should have a look at what queries its doing etc and see if we can speed it up. We can just turn on DEBUG logging on the background worker to see what its doing. |
c.f. #15264 The two changes are: 1. Add indexes so that the select / deletes don't do sequential scans 2. Don't repeatedly call `SELECT count(*)` each iteration, as that's slow
Even after #15435 we seem to still be at about ~1 Hz FTR. |
Bah, that sounds slower than it was before :( |
Relevant code begins here:
synapse/synapse/storage/databases/main/user_directory.py
Line 87 in 335f52d
This process can cause excess load on the DB, perhaps need to reconfigure the batch size to make it less resource-intensive.
The text was updated successfully, but these errors were encountered: