Icinga / Icinga/icinga2

Evaluate memory overhead of icinga::Locked<...> in object attributes

Open
#10,113 4 comments 0 reactions 1 assignee View on GitHub

@julianbrost is already working on this.

Since Jan 13, 2026.

core/evaluate
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
  1. Figure out how much of an effect this has on the total memory use of Icinga 2.

  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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.