Evaluate memory overhead of icinga::Locked<...> in object attributes
@julianbrost is already working on this.
Since Jan 13, 2026.
- Dominant language
- C++
- Stars
- 2.2k
- Forks
- 616
- Avg merge
- 5d 6h
- Merged PRs (30d)
- 10
Description
As a countermeasure for race conditions, #9364 added a mutex for every object attribute with a type that's incompatible with std::atomic. At the moment, that's implemented using a dedicated std::mutex for every attribute for every single object. On my machine, sizeof(std::mutex) = 40, and if I compare the sizeof(icinga::Host) with and without these mutexes, that's a 70% increase. However, that won't result in a 70% increase in memory usage of Icinga 2 as a whole (for example, all strings like object names are dynamically allocated and thus not part of icinga::Host itself and aren't affected by this increase.
Tasks
-
Figure out how much of an effect this has on the total memory use of Icinga 2.
-
Improve this. One idea would be to take some inspiration from how something like
atomic_load(const std::shared_ptr<T>*)is/can be implemented:These functions are typically implemented using mutexes, stored in a global hash table where the pointer value is used as the key.
Note that if using only part of the address as the key, i.e. sharing the mutex between objects, this would reduce the memory requirements.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.