mumble-voip / mumble

Mumble is an open-source, low-latency, high quality voice chat software.
https://www.mumble.info
Other
6.41k stars 1.12k forks source link

Prepared statement caching #3667

Open thomassross opened 5 years ago

thomassross commented 5 years ago

Currently, whenever a statement needs to be executed, we prepare the statement and then throw it away. It would speed up database operations to only prepare the statements once (storing them in a QHash on ServerDB) and re-use the statement, rebinding the values instead of re-preparing the statement.

bendem commented 5 years ago

Have you actually identified a performance problem? Can you share some benchmarks you ran? Or some problems you encountered?

thomassross commented 5 years ago

There are two areas where this is most noticeable: RPC and updateChannel.

Registering a lot of users (2000 in my tests) over RPC while not caching the statements is slower by around 2 seconds than with caching the statements (excluding the RPC overhead).

updateChannel performance can also be improved quite significantly by caching statements, especially where all the groups are deleted and recreated, but I think that is a two-part problem: a) statements should be cached here b) we should not be deleting all of this data from the database and recreating it. This part is a separate issue entirely, but I think it's worth mentioning here.

This isn't going to make a huge difference for small servers with no RPC usage, but for large servers that use RPC for user management, it will.