From edd80b2600d88771485424bcb5d8295f1902af9f Mon Sep 17 00:00:00 2001 From: stratself Date: Tue, 10 Mar 2026 11:22:15 +0000 Subject: [PATCH] docs(perf-tuning): Add bottommost compression section and other changes * docs: Move typing/readmarks disabling section up, and separate outbound sending disablement from total disablement of features * docs: Change introduction tone to "get more out of your server", remove wrong notion of tuned for small instances --- docs/advanced/performance.md | 89 +++++++++++++++++++++++++++--------- 1 file changed, 67 insertions(+), 22 deletions(-) diff --git a/docs/advanced/performance.md b/docs/advanced/performance.md index 1bda51033..69804b932 100644 --- a/docs/advanced/performance.md +++ b/docs/advanced/performance.md @@ -1,6 +1,6 @@ # Performance tuning -While Continuwuity's default config parameters are optimized for a small instance, they would likely need additional modifications to smoothly run in a larger context. This is especially true for homeservers with many users and/or are joined in many large federated rooms, and will increasingly be the case as the Matrix network expands. +While Continuwuity's default config parameters are generally optimized, additional modifications can be made to better utilize your server resources. This is especially helpful for homeservers with many users and/or are joined in many large federated rooms, and will increasingly be the case as the Matrix network expands. This page aims to outline various performance tweaks for Continuwuity and their effects. As always, your mileage may vary according to your setup's specifics. If you have further discussions or recommendations, please share them in the community rooms. @@ -12,17 +12,58 @@ Please see the dedicated DNS tuning guide. ## Cache capacities -If you have unused memory to spare, consider increasing the `cache_capacity_modifier` value to a larger number, as to allow more data to be stored in hot memory. This would _significantly_ speed up many intensive operations such as state resolutions, and also result in decreased CPU usage and disk I/O. Start with a baseline of `cache_capacity_modifier = 2.0` and tune up until you find a satisfactory RAM usage. +If you have unused memory to spare, consider increasing the `cache_capacity_modifier` value to a larger number, as to allow more data to be stored in hot memory. This would _significantly_ speed up many intensive operations such as state resolutions, and also results in decreased CPU usage and disk I/O. Start with a baseline of `cache_capacity_modifier = 2.0` and tune up until you find a satisfactory RAM usage. On the other hand, if your system doesn't have a lot of RAM, consider decreasing the cache capacity modifier to something smaller than `1.0` to avoid low-memory issues (at the cost of higher load on disk/CPU). The recommendation also works if your system has very few RAM compared to the number of cores, as cache capacities tend to scale according to the latter. -## Changing database compression algorithm + +## Disabling some features + +You can disable outgoing **typing notifications** and **read markers** to reduce strain on the CPU and network. + +```toml +# disables sending read receipts +allow_outgoing_read_receipts = false +# disables sending typing notifications +allow_incoming_typing = false +``` + +Outgoing presence updates is also considered expensive and is disabled by default(`allow_local_presence = false`). + +For even more savings, you may wish to disable _all_ processing of typing notifications, read markers, and presence entirely. This can be done by also disabling the local and incoming events for these features. + +
+ + `continuwuity.toml` + +```toml +# disabling read receipts entirely +allow_local_read_receipts = false +allow_incoming_read_receipts = false +allow_outgoing_read_receipts = false + +# disabling typing notifications entirely +allow_local_typing = false +allow_outgoing_typing = false +allow_incoming_typing = false + +# disabling presence updates entirely +allow_local_presence = false +allow_incoming_presence = false +allow_outgoing_presence = false +``` + +
+ +## Tuning database compression :::warning -This step should be done **before** starting Continuwuity for the first time +These steps MUST be done **before** starting Continuwuity for the first time, as database compressions are irreversible ::: -For reduced CPU usage at a tradeoff of increased storage space, consider deploying Continuwuity with the less intensive `lz4` algorithm instead of `zstd` for rocksdb, and disable WAL compression entirely: +### Changing the compression algorithm + +For reduced CPU usage at a tradeoff of increased storage space, consider deploying Continuwuity with the faster and less intensive `lz4` algorithm instead of `zstd` for rocksdb, and disable WAL compression entirely: ```toml ### in continuwuity.toml ### @@ -32,29 +73,33 @@ rocksdb_wal_compression = "none" The tweak can especially be helpful if you have an older or less performant CPU (e.g. a Raspberry Pi) and disk space to spare. -## Disabling some features +### Increasing bottommost layer compression (`zstd` only) -You can consider disabling **typing notifications** and **read markers** to reduce strain on the CPU and network, especially for outbound requests. +The bottommost layer of the database usually contains old and read-only data, and hence is a suitable place for further compression. In Continuwuity, this is possible by setting `rocksdb_bottommost_compression = true` and tuning `rocksdb_bottommost_compression_level` to a more compact level than the default one used in `rocksdb_compression_level`. The tweak comes at a cost of some increased CPU usage, but would prevent your database from growing too large especially in the long run. + +For those using `zstd` compression, the compression level ranges from 1 to 22. An example like this could apply: ```toml -# disabling read receipts -allow_local_read_receipts = false -allow_incoming_read_receipts = false -allow_outgoing_read_receipts = false - -# disabling typing notifications -allow_local_typing = false -allow_outgoing_typing = false -allow_incoming_typing = false +### in continuwuity.toml ### +rocksdb_compression_algo = "zstd" +rocksdb_compression_level = 32767 # magic number, translates to level 3 on zstd +rocksdb_bottommost_compression = true +rocksdb_bottommost_compression_level = 9 # level 9 on zstd ``` -Presence is also considered expensive and is disabled by default. For reference, you can also disable them manually as follows: +For `lz4` users, the default level (`-1`) is already the most compact. You can only further decrease it to favor compression speed over ratio. -```toml -allow_local_presence = false -allow_incoming_presence = false -allow_outgoing_presence = false -``` +Consult these documentations for more information on compression tuning and levels: + +- [Rocksdb compression documentation][rocksdb-compression] +- [Rocksdb default compression levels][rocksdb-compression-defaults] +- [Zstd manual][zstd-manual] +- [Lz4 manual][lz4-manual] + +[rocksdb-compression]: https://github.com/facebook/rocksdb/wiki/Compression +[rocksdb-compression-defaults]: https://github.com/facebook/rocksdb/blob/main/include/rocksdb/options.h#L208-L217 +[zstd-manual]: https://facebook.github.io/zstd/zstd_manual.html +[lz4-manual]: https://github.com/lz4/lz4/blob/release/doc/lz4_manual.html ## Other tweaks