icinga2
icinga2 copied to clipboard
Don't write icinga2.debug file
At the moment, Icinga 2 writes the /var/cache/icinga2/icinga2.debug file every time it loads a config (that is, config validation and daemon startup including reload). Analyzing icinga2 daemon -C using a profiler shows that a solid 17% of the total time is spent in icinga::ConfigCompilerContext::WriteObject(), i.e. duming the object to the icinga2.debug file. Most of the time in there is spent in icinga::JsonEncode(). So not writing this file each time show great potential to speed up reload times.
The main purpose of this file is to be the data source for the icinga2 object list command, which you typically only need when debugging issues, in all other cases, writing this file is a waste of time.
Two options for improving this:
- Adding an extra flag to only generate the file if needed, so to use
icinga2 object list, you'd have to run something likeicinga2 daemon -C --dump-objectsfirst. - Rework
icinga2 object listso that it does not read theicinga2.debugfile but rather talks to the running daemon to get that information. For this, a new local socket would be needed, but looks like Windows still is an open question (looks like support for AF_UNIX was added around 2018, but that's probably not yet available in all relevant server versions). This option has the additional advantage thaticinga2 object listwould always output up-to-date information just as it's used by the daemon, whereas now, it could show newer (config modified,icinga2 daemon -Cbut no reload) or older (API-modified object, no daemon reload or config validation since then) information than used by the daemon.
My first thought was that #7349 could serve as a basis for this feature, but that seems to add the socket to the umbrella process, so that's not really what we'd need here.
This is what's currently written to icinga2.debug:
https://github.com/Icinga/icinga2/blob/a51c004f548265941d089cc2034688a4e91d9701/lib/config/configitem.cpp#L288-L300
Everything except debug_hints, everything is already available at runtime. debug_hints is what is responsible for these lines in icinga2 object list:
% = modified in '/etc/icinga2/zones.d/master/notifications.conf', lines 10:2-10:24