Skip to content

Commit

Permalink
metricd: remove janitor process
Browse files Browse the repository at this point in the history
This merge the janitor process in the worker 0 of the metric processor. This
saves some megabytes of memory.

Closes #652
  • Loading branch information
jd committed Jan 30, 2018
1 parent 081e051 commit 00ff687
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
22 changes: 9 additions & 13 deletions gnocchi/cli/metricd.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ def __init__(self, worker_id, conf):
self._get_sacks_to_process = cachetools.func.ttl_cache(
ttl=conf.metricd.metric_processing_delay
)(self._get_sacks_to_process)
if worker_id == 0:
self.name = "processing+janitor"
self._last_expunge = utils.StopWatch().start()

@tenacity.retry(
wait=utils.wait_exponential,
Expand Down Expand Up @@ -217,6 +220,12 @@ def _get_sacks_to_process(self):
return self._tasks or self.fallback_tasks

def _run_job(self):
if (self.worker_id == 0 and
self._last_expunge.elapsed()
>= self.conf.metric.metric_cleanup_delay):
self.store.expunge_metrics(self.incoming, self.index)
self._last_expunge.reset()

m_count = 0
s_count = 0
# We are going to process the sacks we got notified for, and if we got
Expand Down Expand Up @@ -258,18 +267,6 @@ def close_services(self):
self.coord.stop()


class MetricJanitor(MetricProcessBase):
name = "janitor"

def __init__(self, worker_id, conf):
super(MetricJanitor, self).__init__(
worker_id, conf, conf.metricd.metric_cleanup_delay)

def _run_job(self):
self.store.expunge_metrics(self.incoming, self.index)
LOG.debug("Metrics marked for deletion removed from backend")


class MetricdServiceManager(cotyledon.ServiceManager):
def __init__(self, conf):
super(MetricdServiceManager, self).__init__()
Expand All @@ -281,7 +278,6 @@ def __init__(self, conf):
workers=conf.metricd.workers)
if self.conf.metricd.metric_reporting_delay >= 0:
self.add(MetricReporting, args=(self.conf,))
self.add(MetricJanitor, args=(self.conf,))

self.register_hooks(on_reload=self.on_reload)

Expand Down
2 changes: 1 addition & 1 deletion gnocchi/opts.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def list_opts():
deprecated_group='storage',
default=300,
required=True,
help="How many seconds to wait between "
help="How many seconds to wait (at least) between "
"cleaning of expired data"),
cfg.IntOpt('processing_replicas',
default=3,
Expand Down

0 comments on commit 00ff687

Please sign in to comment.