]> git.ipfire.org Git - thirdparty/pdns.git/commit
dnsdist: Improve scalability of custom metrics 15524/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 5 May 2025 15:03:06 +0000 (17:03 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 5 May 2025 15:05:26 +0000 (17:05 +0200)
commitb56dc4bb1ca04ea6855474838c66db453055fdd9
treec32bc84642770a585a7b00e5bcb348097449e438
parent612805d16018630088c39941689247439c8b1d7c
dnsdist: Improve scalability of custom metrics

This commit improves the scalability of custom metrics by:
- being optimistic about the existence of a given metric (including labels):
  since most of the time a given metric, even with labels, will be increased
  more than once, we can take read-only lock and only fallback to taking a
  write lock if we actually have to add a new entry. This is especially
  useful when using custom metrics with per-thread Lua, since there is no
  global lock involved in this case.
- optimizing the "no label" case, since the Lua FFI interface does not
  use anyway: skip the creation (and destruction) of an empty labels
  map whenever possible, return an empty string early when combining
  empty labels.

It already yields a noticeable improvement when a single thread is used,
but really shines when several threads are processing queries simultaneously.
pdns/dnsdistdist/dnsdist-lua-ffi.cc
pdns/dnsdistdist/dnsdist-metrics.cc
pdns/dnsdistdist/dnsdist-metrics.hh