From: bert hubert Date: Mon, 1 Apr 2019 13:48:55 +0000 (+0200) Subject: add comments X-Git-Tag: rec-4.1.12~2^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F7647%2Fhead;p=thirdparty%2Fpdns.git add comments --- diff --git a/pdns/rec_channel_rec.cc b/pdns/rec_channel_rec.cc index e130ec58b5..a16b436229 100644 --- a/pdns/rec_channel_rec.cc +++ b/pdns/rec_channel_rec.cc @@ -657,6 +657,14 @@ static uint64_t getUserTimeMsec() return (ru.ru_utime.tv_sec*1000ULL + ru.ru_utime.tv_usec/1000); } +/* This is a pretty weird set of functions. To get per-thread cpu usage numbers, + we have to ask a thread over a pipe. We could do so surgically, so if you want to know about + thread 3, we pick pipe 3, but we lack that infrastructure. + + We can however ask "execute this function on all threads and add up the results". + This is what the first function does using a custom object ThreadTimes, which if you add + to each other keeps filling the first one with CPU usage numbers +*/ ThreadTimes* pleaseGetThreadCPUMsec() { @@ -670,6 +678,12 @@ ThreadTimes* pleaseGetThreadCPUMsec() return new ThreadTimes{ret}; } +/* Next up, when you want msec data for a specific thread, we check + if we recently executed pleaseGetThreadCPUMsec. If we didn't we do so + now and consult all threads. + + We then answer you from the (re)fresh(ed) ThreadTimes. +*/ uint64_t doGetThreadCPUMsec(int n) { static std::mutex s_mut;