comparison OrthancServer/Resources/ImplementationNotes/memory_consumption.txt @ 5346:566e8d32bd3a

Reduce the frequency of memory trimming from 100ms to 30s to avoid high idle CPU load
author Alain Mazy <am@osimis.io>
date Thu, 29 Jun 2023 09:43:20 +0200
parents f5907aecbaed
children
comparison
equal deleted inserted replaced
5342:65d55cc86a41 5346:566e8d32bd3a
1 In Orthanc 1.11.3, we have introduced a Housekeeper thread that 1 In Orthanc 1.11.3, we have introduced a Housekeeper thread that
2 tries to give back unused memory back to the system. This is implemented 2 tries to give back unused memory back to the system. This is implemented
3 by calling malloc_trim every 100ms. 3 by calling malloc_trim every 30s (note: on 1.11.3 and 1.12.0, the interval
4 was 100ms which caused high idle CPU load).
4 5
5 6
6 Here is how we validated the effect of this new feature: 7 Here is how we validated the effect of this new feature:
7 ------------------------------------------------------- 8 -------------------------------------------------------
8 9
131 M_MMAP_THRESHOLD parameter. 132 M_MMAP_THRESHOLD parameter.
132 - free() employs sbrk() to release memory back to the system and M_TRIM_THRESHOLD 133 - free() employs sbrk() to release memory back to the system and M_TRIM_THRESHOLD
133 specifies the minimum size that is released. So, even without 134 specifies the minimum size that is released. So, even without
134 malloc_trim, Orthanc is able to give back memory to the system. 135 malloc_trim, Orthanc is able to give back memory to the system.
135 - free() never gives back block allocated by mmap() to the system, only malloc_trim() does ! 136 - free() never gives back block allocated by mmap() to the system, only malloc_trim() does !
137
138 UPDATE on June 2023:
139 -------------------
140
141 Given this discussion: https://discourse.orthanc-server.org/t/onchange-callbacks-and-cpu-loads/3534,
142 changed the interval from 100ms to 30s.
143 We also added a metrics to monitor the duration: orthanc_memory_trimming_duration_ms
144
145 Good reference article:
146 https://www.algolia.com/blog/engineering/when-allocators-are-hoarding-your-precious-memory/
147
148
149