diff --git a/docs/maintenance-synapse.md b/docs/maintenance-synapse.md index 0c85d3804..0ffe0e00a 100644 --- a/docs/maintenance-synapse.md +++ b/docs/maintenance-synapse.md @@ -82,12 +82,12 @@ Tuning Synapse's cache factor is useful for performance increases but also as pa Tuning the cache factor is useful only to a limited degree as its crude to do in isolation and therefore users who are tuning their cache factor should likely look into tuning the autotune variables also. -Cache autotune is controlled primarily via the following variables `matrix_synapse_caches_autotuning_max_cache_memory_usage: ""` `matrix_synapse_caches_autotuning_target_cache_memory_usage: ""` `matrix_synapse_caches_autotuning_min_cache_ttl: ""` +Cache autotune is controlled primarily via the following variables `matrix_synapse_cache_autotuning_max_cache_memory_usage: ""` `matrix_synapse_cache_autotuning_target_cache_memory_usage: ""` `matrix_synapse_cache_autotuning_min_cache_ttl: ""` -The `matrix_synapse_caches_autotuning_max_cache_memory_usage: ""` variable controls the maximum amount of ram Synapse is allowed to use before synapse aggressively tries to get rid of cache until you either hit `matrix_synapse_caches_autotuning_min_cache_ttl: ""` being the age of your cache or you hit your memory use target set by `matrix_synapse_caches_autotuning_target_cache_memory_usage: ""` +The `matrix_synapse_cache_autotuning_max_cache_memory_usage: ""` variable controls the maximum amount of ram Synapse is allowed to use before synapse aggressively tries to get rid of cache until you either hit `matrix_synapse_cache_autotuning_min_cache_ttl: ""` being the age of your cache or you hit your memory use target set by `matrix_synapse_cache_autotuning_target_cache_memory_usage: ""` -The playbook defaults these settings to `1/8 of system ram up to 2048mb` for max use and `1/16 of system ram up to 1024MB` as target and `30s` as the minimum age of cache entries that are allowed to be evicted by autotune. +The playbook defaults these settings to `1/8 of system ram up to 2048mb` for max use and `1/16 of system ram up to 1024MB` as target and `30s` as the minimum age of cache entries that are allowed to be evicted by autotune. -Users who wish to lower Synapses RAM footprint should look at lowering cache factor together with autotune variables. If your cache factor is too low for a given auto tune setting your caches will not reach auto tune thresholds and therefore autotune wont be doing its job. Therefore its recommended to when running auto tune have your cache factor be too big by a resonable margin instead as to be able to have full use of autotune. +Users who wish to lower Synapses RAM footprint should look at lowering cache factor together with autotune variables. If your cache factor is too low for a given auto tune setting your caches will not reach auto tune thresholds and therefore autotune wont be doing its job. Therefore its recommended to when running auto tune have your cache factor be too big by a resonable margin instead as to be able to have full use of autotune. See also [How do I optimize this setup for a low-power server?](faq.md#how-do-i-optimize-this-setup-for-a-low-power-server). diff --git a/roles/custom/matrix-synapse/defaults/main.yml b/roles/custom/matrix-synapse/defaults/main.yml index 0a4138ce3..d3aa8a62f 100644 --- a/roles/custom/matrix-synapse/defaults/main.yml +++ b/roles/custom/matrix-synapse/defaults/main.yml @@ -556,13 +556,13 @@ matrix_synapse_caches_global_factor: 10 matrix_synapse_caches_expire_caches: true matrix_synapse_caches_cache_entry_ttl: "1080m" matrix_synapse_caches_sync_response_cache_duration: "2m" -matrix_synapse_caches_autotuning_min_cache_ttl: "30s" +matrix_synapse_cache_autotuning_min_cache_ttl: "30s" # The Cache tune math used here is a derivative of the same math used to autotune sizes for postgres. # The memtotal variable can in theory be overiden to make Synapse think it has less ram to work with. # But if your at the point of considering that just override the math or put static values in. matrix_synapse_memtotal_kb: "{{ ansible_memtotal_mb*1024|int }}" -matrix_synapse_caches_autotuning_max_cache_memory_usage: "{{ 2097152 if (matrix_synapse_memtotal_kb|int/8)/1024 >= 2048 else matrix_synapse_memtotal_kb|int/8 }}" -matrix_synapse_caches_autotuning_target_cache_memory_usage: "{{ 1048576 if (matrix_synapse_memtotal_kb|int/16)/1024 >= 1024 else matrix_synapse_memtotal_kb|int/16 }}" +matrix_synapse_cache_autotuning_max_cache_memory_usage: "{{ 2097152 if (matrix_synapse_memtotal_kb|int/8)/1024 >= 2048 else matrix_synapse_memtotal_kb|int/8 }}" +matrix_synapse_cache_autotuning_target_cache_memory_usage: "{{ 1048576 if (matrix_synapse_memtotal_kb|int/16)/1024 >= 1024 else matrix_synapse_memtotal_kb|int/16 }}" # Controls whether Synapse will federate at all. # Disable this to completely isolate your server from the rest of the Matrix network. diff --git a/roles/custom/matrix-synapse/tasks/validate_config.yml b/roles/custom/matrix-synapse/tasks/validate_config.yml index cea1d4bee..0418c9ec1 100644 --- a/roles/custom/matrix-synapse/tasks/validate_config.yml +++ b/roles/custom/matrix-synapse/tasks/validate_config.yml @@ -84,6 +84,9 @@ - {'old': 'matrix_synapse_send_federation', 'new': ''} - {'old': 'matrix_synapse_start_pushers', 'new': ''} - {'old': 'matrix_synapse_spam_checker', 'new': ''} + - {'old': 'matrix_synapse_caches_autotuning_max_cache_memory_usage', 'new': 'matrix_synapse_cache_autotuning_max_cache_memory_usage'} + - {'old': 'matrix_synapse_caches_autotuning_target_cache_memory_usage', 'new': 'matrix_synapse_cache_autotuning_target_cache_memory_usage'} + - {'old': 'matrix_synapse_caches_autotuning_min_cache_ttl', 'new': 'matrix_synapse_cache_autotuning_min_cache_ttl'} - name: (Deprecation) Catch and report renamed settings in matrix_synapse_configuration_extension_yaml ansible.builtin.fail: diff --git a/roles/custom/matrix-synapse/templates/synapse/homeserver.yaml.j2 b/roles/custom/matrix-synapse/templates/synapse/homeserver.yaml.j2 index 71c7606ce..aee476c3b 100644 --- a/roles/custom/matrix-synapse/templates/synapse/homeserver.yaml.j2 +++ b/roles/custom/matrix-synapse/templates/synapse/homeserver.yaml.j2 @@ -817,9 +817,9 @@ caches: # for information for now # cache_autotuning: - max_cache_memory_usage: {{ matrix_synapse_caches_autotuning_max_cache_memory_usage | to_json }} - target_cache_memory_usage: {{ matrix_synapse_caches_autotuning_target_cache_memory_usage | to_json }} - min_cache_ttl: {{ matrix_synapse_caches_autotuning_min_cache_ttl | to_json }} + max_cache_memory_usage: {{ matrix_synapse_cache_autotuning_max_cache_memory_usage | to_json }} + target_cache_memory_usage: {{ matrix_synapse_cache_autotuning_target_cache_memory_usage | to_json }} + min_cache_ttl: {{ matrix_synapse_cache_autotuning_min_cache_ttl | to_json }} ## Database ##