mirror of
https://github.com/element-hq/synapse
synced 2024-06-30 19:33:30 +00:00
Make TRACK_MEMORY_USAGE configurable
This commit is contained in:
parent
0c9bab290f
commit
567fe5e387
|
@ -452,6 +452,7 @@ def start(config_options):
|
|||
config.server.update_user_directory = False
|
||||
|
||||
synapse.events.USE_FROZEN_DICTS = config.use_frozen_dicts
|
||||
synapse.util.caches.lrucache.TRACK_MEMORY_USAGE = config.caches.track_memory_usage
|
||||
|
||||
hs = GenericWorkerServer(
|
||||
config.server_name,
|
||||
|
|
|
@ -339,6 +339,7 @@ def setup(config_options):
|
|||
sys.exit(0)
|
||||
|
||||
events.USE_FROZEN_DICTS = config.use_frozen_dicts
|
||||
synapse.util.caches.lrucache.TRACK_MEMORY_USAGE = config.caches.track_memory_usage
|
||||
|
||||
hs = SynapseHomeServer(
|
||||
config.server_name,
|
||||
|
|
|
@ -17,6 +17,8 @@ import re
|
|||
import threading
|
||||
from typing import Callable, Dict
|
||||
|
||||
from synapse.python_dependencies import DependencyException, check_requirements
|
||||
|
||||
from ._base import Config, ConfigError
|
||||
|
||||
# The prefix for all cache factor-related environment variables
|
||||
|
@ -189,6 +191,15 @@ class CacheConfig(Config):
|
|||
)
|
||||
self.cache_factors[cache] = factor
|
||||
|
||||
self.track_memory_usage = cache_config.get("track_memory_usage", False)
|
||||
if self.track_memory_usage:
|
||||
try:
|
||||
check_requirements("cache_memory")
|
||||
except DependencyException as e:
|
||||
raise ConfigError(
|
||||
e.message # noqa: B306, DependencyException.message is a property
|
||||
)
|
||||
|
||||
# Resize all caches (if necessary) with the new factors we've loaded
|
||||
self.resize_all_caches()
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ CONDITIONAL_REQUIREMENTS = {
|
|||
# hiredis is not a *strict* dependency, but it makes things much faster.
|
||||
# (if it is not installed, we fall back to slow code.)
|
||||
"redis": ["txredisapi>=1.4.7", "hiredis"],
|
||||
"cache_memroy": ["pympler"],
|
||||
"cache_memory": ["pympler"],
|
||||
}
|
||||
|
||||
ALL_OPTIONAL_REQUIREMENTS = set() # type: Set[str]
|
||||
|
|
|
@ -60,7 +60,7 @@ except ImportError:
|
|||
|
||||
|
||||
# Whether to track estimated memory usage of the LruCaches.
|
||||
TRACK_MEMORY_USAGE = True
|
||||
TRACK_MEMORY_USAGE = False
|
||||
|
||||
|
||||
# Function type: the type used for invalidation callbacks
|
||||
|
|
Loading…
Reference in a new issue