Module: check_mk
Branch: master
Commit: ebd1d1ef16ba701bccfcead24ba59dea31672d2e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ebd1d1ef16ba70…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Jan 16 14:32:29 2018 +0100
5649 FIX Fixed performance issue caused by too many parse function calls
Fixed a regression that was introduced with 1.5.0i2. The parse functions
were called not only once per Check_MK check, as it is intended. Each
service of a Check_MK check lead to a new call of the parse function logic.
For example in case you have 100 services of a single check type on one host,
the parse logic was called a hundred times instead of a single time.
Change-Id: I66cb6c08393bab567f017c6e20f0cbf134b37173
---
.werks/5649 | 15 +++++++++++++++
cmk_base/data_sources/host_sections.py | 11 +++++++++++
2 files changed, 26 insertions(+)
diff --git a/.werks/5649 b/.werks/5649
new file mode 100644
index 0000000..e2bb6b9
--- /dev/null
+++ b/.werks/5649
@@ -0,0 +1,15 @@
+Title: Fixed performance issue caused by too many parse function calls
+Level: 1
+Component: core
+Compatible: compat
+Edition: cre
+Version: 1.5.0i3
+Date: 1516109439
+Class: fix
+
+Fixed a regression that was introduced with 1.5.0i2. The parse functions
+were called not only once per Check_MK check, as it is intended. Each
+service of a Check_MK check lead to a new call of the parse function logic.
+
+For example in case you have 100 services of a single check type on one host,
+the parse logic was called a hundred times instead of a single time.
diff --git a/cmk_base/data_sources/host_sections.py
b/cmk_base/data_sources/host_sections.py
index 68742fe..2432384 100644
--- a/cmk_base/data_sources/host_sections.py
+++ b/cmk_base/data_sources/host_sections.py
@@ -32,6 +32,7 @@ import cmk.debug
import cmk_base.console as console
import cmk_base.config as config
import cmk_base.checks as checks
+import cmk_base.caching as caching
import cmk_base.ip_lookup as ip_lookup
import cmk_base.item_state as item_state
@@ -93,6 +94,7 @@ class MultiHostSections(object):
def __init__(self):
super(MultiHostSections, self).__init__()
self._multi_host_sections = {}
+ self._section_content_cache = caching.DictCache()
def add_or_get_host_sections(self, host_name, ipaddress, deflt=None):
@@ -125,6 +127,15 @@ class MultiHostSections(object):
It can return an section_content construct or None when there is no section
content
for this check available.
"""
+ try:
+ return self._section_content_cache[(hostname, ipaddress, check_plugin_name,
for_discovery)]
+ except KeyError:
+ section_content = self._get_section_content(hostname, ipaddress,
check_plugin_name, for_discovery)
+ self._section_content_cache[(hostname, ipaddress, check_plugin_name,
for_discovery)] = section_content
+ return section_content
+
+
+ def _get_section_content(self, hostname, ipaddress, check_plugin_name,
for_discovery):
section_name = checks.section_name_of(check_plugin_name)
# First abstract cluster / non cluster hosts