SolidWallOfCode commented on code in PR #9114:
URL: https://github.com/apache/trafficserver/pull/9114#discussion_r984771761
##########
iocore/eventsystem/UnixEThread.cc:
##########
@@ -289,26 +292,31 @@ EThread::execute_regular()
// loop cleanup
loop_finish_time = Thread::get_hrtime_updated();
- delta = loop_finish_time - loop_start_time;
-
- // This can happen due to time of day adjustments (which apparently happen
quite frequently). I
+ // @a delta can be negative due to time of day adjustments (which
apparently happen quite frequently). I
// tried using the monotonic clock to get around this but it was *very*
stuttery (up to hundreds
// of milliseconds), far too much to be actually used.
- if (delta > 0) {
- if (delta > current_metric->_loop_time._max) {
- current_metric->_loop_time._max = delta;
- }
- if (delta < current_metric->_loop_time._min) {
- current_metric->_loop_time._min = delta;
- }
+ delta = std::max<ink_hrtime>(0, loop_finish_time - loop_start_time);
+
+ if (delta > metrics.current_slice->_duration._max) {
+ metrics.current_slice->_duration._max = delta;
+ }
+ if (delta < metrics.current_slice->_duration._min) {
+ metrics.current_slice->_duration._min = delta;
}
- if (ev_count < current_metric->_events._min) {
- current_metric->_events._min = ev_count;
+ if (ev_count < metrics.current_slice->_events._min) {
+ metrics.current_slice->_events._min = ev_count;
}
- if (ev_count > current_metric->_events._max) {
- current_metric->_events._max = ev_count;
+ if (ev_count > metrics.current_slice->_events._max) {
+ metrics.current_slice->_events._max = ev_count;
}
- current_metric->_events._total += ev_count;
+ metrics.current_slice->_events._total += ev_count;
+ // Take care of any data decay.
+ while (metrics._decay_count) {
+ metrics._loop_timing.decay();
+ metrics._api_timing.decay();
+ --metrics._decay_count;
+ }
+ metrics._loop_timing(delta /
std::chrono::duration_cast<std::chrono::nanoseconds>(Metrics::LOOP_HISTOGRAM_BUCKET_SIZE).count());
Review Comment:
Or add `Metric::decay`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]