@@ -64,6 +64,50 @@ app: synapse
6464component: synapse-{{ . }}
6565{{- end }}
6666
67+ {{/*
68+ Base helper for Synapse cache size limits.
69+ Falls back to .fallback when no limit is configured or suffix is unrecognised.
70+ Supported Kubernetes suffixes: Gi, Mi, G, M.
71+ */ }}
72+ {{- define " synapse.workerCacheMemory" -}}
73+ {{- $resources := .options.resources | default .defaults -}}
74+ {{- $memLimit := " " -}}
75+ {{- if and $resources $resources .limits $resources .limits.memory -}}
76+ {{- $memLimit = $resources .limits.memory | toString -}}
77+ {{- end -}}
78+ {{- $num := .num -}}
79+ {{- $denom := .denom -}}
80+ {{- if $memLimit -}}
81+ {{- if hasSuffix " Gi" $memLimit -}}
82+ {{- $val := trimSuffix " Gi" $memLimit | int64 -}}
83+ {{- printf " %d M" (div (mul (mul $val 1024) $num ) $denom ) -}}
84+ {{- else if hasSuffix " Mi" $memLimit -}}
85+ {{- $val := trimSuffix " Mi" $memLimit | int64 -}}
86+ {{- printf " %d M" (div (mul $val $num ) $denom ) -}}
87+ {{- else if hasSuffix " G" $memLimit -}}
88+ {{- $val := trimSuffix " G" $memLimit | int64 -}}
89+ {{- printf " %d M" (div (mul (mul $val 1024) $num ) $denom ) -}}
90+ {{- else if hasSuffix " M" $memLimit -}}
91+ {{- $val := trimSuffix " M" $memLimit | int64 -}}
92+ {{- printf " %d M" (div (mul $val $num ) $denom ) -}}
93+ {{- else -}}
94+ {{- .fallback -}}
95+ {{- end -}}
96+ {{- else -}}
97+ {{- .fallback -}}
98+ {{- end -}}
99+ {{- end -}}
100+
101+ {{/* max_cache_memory_usage = 90% of memory limit */ }}
102+ {{- define " synapse.workerMaxCacheMemory" -}}
103+ {{- include " synapse.workerCacheMemory" (merge (dict " num" 9 " denom" 10) . ) -}}
104+ {{- end -}}
105+
106+ {{/* target_cache_memory_usage = 80% of max = 72% of memory limit */ }}
107+ {{- define " synapse.workerTargetCacheMemory" -}}
108+ {{- include " synapse.workerCacheMemory" (merge (dict " num" 72 " denom" 100) . ) -}}
109+ {{- end -}}
110+
67111{{/*
68112Workers containers
69113*/ }}
0 commit comments