This is an automated email from the ASF dual-hosted git repository.
cmcfarlen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new 7681065411 Event metrics cleanup (#12565)
7681065411 is described below
commit 7681065411708674f2c01f00c6a698912aa16d33
Author: Chris McFarlen <[email protected]>
AuthorDate: Sun Nov 2 20:51:52 2025 -0500
Event metrics cleanup (#12565)
* Eventloop status use new Metrics
* remove comment
* Fix EventStatsBlock::STAT_COUNT
* Remove P_RecProcess.h
---
include/records/RecProcess.h | 5 +++
src/iocore/cache/CacheProcessor.cc | 3 +-
src/iocore/eventsystem/RecProcess.cc | 1 -
src/iocore/eventsystem/RecRawStatsImpl.cc | 3 +-
src/iocore/eventsystem/UnixEventProcessor.cc | 50 ++++++++++++----------------
src/iocore/net/SSLStats.cc | 2 +-
src/proxy/http2/HTTP2.cc | 2 +-
src/proxy/logging/LogUtils.cc | 2 --
src/records/P_RecProcess.h | 44 ------------------------
src/records/RecRawStats.cc | 2 +-
10 files changed, 33 insertions(+), 81 deletions(-)
diff --git a/include/records/RecProcess.h b/include/records/RecProcess.h
index 8f6ed4d2ae..6bae4553f8 100644
--- a/include/records/RecProcess.h
+++ b/include/records/RecProcess.h
@@ -62,6 +62,11 @@ int RecRawStatSyncIntMsecsToFloatSeconds(const char *name,
RecDataT data_type, R
int RecRegisterRawStatSyncCb(const char *name, RecRawStatSyncCb sync_cb,
RecRawStatBlock *rsb, int id);
int RecRawStatUpdateSum(RecRawStatBlock *rsb, int id);
+int RecExecRawStatSyncCbs();
+
+using RecCallbackFunction = std::function<void()>;
+void RecRegNewSyncStatSync(RecCallbackFunction callback);
+
//-------------------------------------------------------------------------
// RawStat Setting/Getting
//-------------------------------------------------------------------------
diff --git a/src/iocore/cache/CacheProcessor.cc
b/src/iocore/cache/CacheProcessor.cc
index 85b8956e26..e3d217d647 100644
--- a/src/iocore/cache/CacheProcessor.cc
+++ b/src/iocore/cache/CacheProcessor.cc
@@ -35,8 +35,7 @@
#include "iocore/eventsystem/Action.h"
#include "iocore/eventsystem/Continuation.h"
-#include "../../records/P_RecProcess.h"
-
+#include "iocore/eventsystem/Freer.h"
#include "tscore/Diags.h"
#include "tscore/Filenames.h"
#include "tscore/ink_assert.h"
diff --git a/src/iocore/eventsystem/RecProcess.cc
b/src/iocore/eventsystem/RecProcess.cc
index 1940783eff..81d698bab5 100644
--- a/src/iocore/eventsystem/RecProcess.cc
+++ b/src/iocore/eventsystem/RecProcess.cc
@@ -29,7 +29,6 @@
#include "P_EventSystem.h"
#include "../../records/P_RecCore.h"
-#include "../../records/P_RecProcess.h"
#include "../../records/P_RecMessage.h"
#include "../../records/P_RecUtils.h"
#include "../../records/P_RecFile.h"
diff --git a/src/iocore/eventsystem/RecRawStatsImpl.cc
b/src/iocore/eventsystem/RecRawStatsImpl.cc
index 26fe493dbf..fe96d6deed 100644
--- a/src/iocore/eventsystem/RecRawStatsImpl.cc
+++ b/src/iocore/eventsystem/RecRawStatsImpl.cc
@@ -21,9 +21,10 @@ Record statistics support (EThread implementation).
limitations under the License.
*/
+#include "iocore/eventsystem/EventProcessor.h"
#include "records/RecDefs.h"
+#include "records/RecProcess.h"
#include "../../records/P_RecCore.h"
-#include "../../records/P_RecProcess.h"
#include <string_view>
//-------------------------------------------------------------------------
diff --git a/src/iocore/eventsystem/UnixEventProcessor.cc
b/src/iocore/eventsystem/UnixEventProcessor.cc
index 4a834d74b3..4ac2c7f7bb 100644
--- a/src/iocore/eventsystem/UnixEventProcessor.cc
+++ b/src/iocore/eventsystem/UnixEventProcessor.cc
@@ -86,8 +86,14 @@ ThreadAffinityInitializer Thread_Affinity_Initializer;
namespace
{
-int
-EventMetricStatSync(const char *, RecDataT, RecData *, RecRawStatBlock *rsb,
int)
+struct EventStatsBlock {
+ static constexpr size_t STAT_COUNT =
+ EThread::Metrics::Graph::N_BUCKETS * 2 +
EThread::Metrics::Slice::N_STAT_ID * EThread::Metrics::N_TIMESCALES;
+ std::array<ts::Metrics::Gauge::AtomicType *, STAT_COUNT> stats;
+} events_rsb;
+
+void
+EventMetricStatSync()
{
using Graph = EThread::Metrics::Graph;
@@ -99,15 +105,10 @@ EventMetricStatSync(const char *, RecDataT, RecData *,
RecRawStatBlock *rsb, int
t->metrics.summarize(summary);
}
- ink_mutex_acquire(&(rsb->mutex));
-
// Update a specific enumerated stat.
auto slice_stat_update = [=](EThread::Metrics::Slice::STAT_ID stat_id, int
stat_idx, size_t value) {
- auto idx = stat_idx + static_cast<unsigned>(stat_id);
- auto stat = rsb->global[idx];
- stat->sum = value;
- stat->count = 1;
- RecRawStatUpdateSum(rsb, idx);
+ auto idx = stat_idx + static_cast<unsigned>(stat_id);
+ ts::Metrics::Gauge::store(events_rsb.stats[idx], value);
};
// Enumerated stats are first - one set for each time scale.
@@ -129,16 +130,12 @@ EventMetricStatSync(const char *, RecDataT, RecData *,
RecRawStatBlock *rsb, int
// Next are the event loop histogram buckets.
for (Graph::raw_type idx = 0; idx < Graph::N_BUCKETS; ++idx, ++id) {
- rsb->global[id]->sum = summary._loop_timing[idx];
- rsb->global[id]->count = 1;
- RecRawStatUpdateSum(rsb, id);
+ ts::Metrics::Gauge::store(events_rsb.stats[id], summary._loop_timing[idx]);
}
// Last are the plugin API histogram buckets.
for (Graph::raw_type idx = 0; idx < Graph::N_BUCKETS; ++idx, ++id) {
- rsb->global[id]->sum = summary._api_timing[idx];
- rsb->global[id]->count = 1;
- RecRawStatUpdateSum(rsb, id);
+ ts::Metrics::Gauge::store(events_rsb.stats[id], summary._api_timing[idx]);
}
// Check if it's time to schedule a decay of the histogram data.
@@ -150,9 +147,6 @@ EventMetricStatSync(const char *, RecDataT, RecData *,
RecRawStatBlock *rsb, int
++(t->metrics._decay_count);
}
}
-
- ink_mutex_release(&(rsb->mutex));
- return REC_ERR_OKAY;
}
/// This is a wrapper used to convert a static function into a continuation.
The function pointer is
@@ -524,16 +518,15 @@ EventProcessor::start(int n_event_threads, size_t
stacksize)
thread_group[ET_CALL]._spawnQueue.push(make_event_for_scheduling(&Thread_Affinity_Initializer,
EVENT_IMMEDIATE, nullptr));
// Get our statistics set up
- RecRawStatBlock *rsb =
RecAllocateRawStatBlock(EThread::Metrics::N_STATS);
- unsigned stat_idx = 0;
- char name[256];
+ unsigned stat_idx = 0;
+ char name[256];
// Enumerated statistics, one set per time scale.
for (unsigned ts_idx = 0; ts_idx < EThread::Metrics::N_TIMESCALES; ++ts_idx)
{
auto sample_count = EThread::Metrics::SLICE_SAMPLE_COUNT[ts_idx];
- for (unsigned id = 0; id < EThread::Metrics::Slice::N_STAT_ID; ++id) {
- snprintf(name, sizeof(name), "%s.%ds",
EThread::Metrics::Slice::STAT_NAME[id], sample_count);
- RecRegisterRawStat(rsb, RECT_PROCESS, name, RECD_INT,
RECP_NON_PERSISTENT, stat_idx++, NULL);
+ for (auto id : EThread::Metrics::Slice::STAT_NAME) {
+ snprintf(name, sizeof(name), "%s.%ds", id, sample_count);
+ events_rsb.stats[stat_idx++] = ts::Metrics::Gauge::createPtr(name);
}
}
@@ -541,18 +534,19 @@ EventProcessor::start(int n_event_threads, size_t
stacksize)
for (Graph::raw_type id = 0; id < Graph::N_BUCKETS; ++id) {
snprintf(name, sizeof(name), "%s%zums",
EThread::Metrics::LOOP_HISTOGRAM_STAT_STEM.data(),
static_cast<size_t>(EThread::Metrics::LOOP_HISTOGRAM_BUCKET_SIZE.count() *
Graph::min_for_bucket(id)));
- RecRegisterRawStat(rsb, RECT_PROCESS, name, RECD_INT, RECP_NON_PERSISTENT,
stat_idx++, NULL);
+ events_rsb.stats[stat_idx++] = ts::Metrics::Gauge::createPtr(name);
}
// plugin API timings
for (Graph::raw_type id = 0; id < Graph::N_BUCKETS; ++id) {
snprintf(name, sizeof(name), "%s%zums",
EThread::Metrics::API_HISTOGRAM_STAT_STEM.data(),
static_cast<size_t>(EThread::Metrics::API_HISTOGRAM_BUCKET_SIZE.count() *
Graph::min_for_bucket(id)));
- RecRegisterRawStat(rsb, RECT_PROCESS, name, RECD_INT, RECP_NON_PERSISTENT,
stat_idx++, NULL);
+ events_rsb.stats[stat_idx++] = ts::Metrics::Gauge::createPtr(name);
}
- // Name must be that of a stat, pick one at random since we do all of them
in one pass/callback.
- RecRegisterRawStatSyncCb(name, EventMetricStatSync, rsb, 0);
+ debug_assert_message(stat_idx == events_rsb.stats.size(), "events_rsp stats
overrun!");
+
+ RecRegNewSyncStatSync(EventMetricStatSync);
this->spawn_event_threads(ET_CALL, n_event_threads, stacksize);
diff --git a/src/iocore/net/SSLStats.cc b/src/iocore/net/SSLStats.cc
index ee8c6cb629..5d0b90c74c 100644
--- a/src/iocore/net/SSLStats.cc
+++ b/src/iocore/net/SSLStats.cc
@@ -24,8 +24,8 @@
#include "SSLStats.h"
#include "P_SSLConfig.h"
#include "P_SSLUtils.h"
-#include "../../records/P_RecProcess.h"
#include "iocore/net/SSLMultiCertConfigLoader.h"
+#include "records/RecProcess.h"
#include <openssl/err.h>
diff --git a/src/proxy/http2/HTTP2.cc b/src/proxy/http2/HTTP2.cc
index a772639dbd..620ccc8f4e 100644
--- a/src/proxy/http2/HTTP2.cc
+++ b/src/proxy/http2/HTTP2.cc
@@ -21,6 +21,7 @@
* limitations under the License.
*/
+#include "iocore/eventsystem/IOBuffer.h"
#include "proxy/hdrs/VersionConverter.h"
#include "proxy/hdrs/HeaderValidator.h"
#include "proxy/http2/HTTP2.h"
@@ -30,7 +31,6 @@
#include "tsutil/LocalBuffer.h"
#include "../../records/P_RecCore.h"
-#include "../../records/P_RecProcess.h"
const char *const HTTP2_CONNECTION_PREFACE = "PRI *
HTTP/2.0\r\n\r\nSM\r\n\r\n";
diff --git a/src/proxy/logging/LogUtils.cc b/src/proxy/logging/LogUtils.cc
index 16bd56dbba..e88a2002b3 100644
--- a/src/proxy/logging/LogUtils.cc
+++ b/src/proxy/logging/LogUtils.cc
@@ -59,8 +59,6 @@ using namespace std::literals;
#include <arpa/inet.h>
#include <netdb.h>
-#include "../../records/P_RecProcess.h"
-
#include "proxy/logging/LogUtils.h"
#include "proxy/logging/LogLimits.h"
diff --git a/src/records/P_RecProcess.h b/src/records/P_RecProcess.h
deleted file mode 100644
index 40f34c6738..0000000000
--- a/src/records/P_RecProcess.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/** @file
-
- Private record process declarations
-
- @section license License
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
-
-#pragma once
-
-// Must include 'P_EventSystem.h' before 'I_EventSystem.h' (which is
-// included in 'I_RecProcess.h') to prevent multiple-symbol-definition
-// complaints if the caller uses both 'P_EventSystem.h' and this 'P_'
-// file.
-#include "../iocore/eventsystem/P_EventSystem.h"
-
-#include "records/RecProcess.h"
-#include "P_RecDefs.h"
-
-#include <functional>
-
-//-------------------------------------------------------------------------
-// Protected Interface
-//-------------------------------------------------------------------------
-
-int RecExecRawStatSyncCbs();
-
-using RecCallbackFunction = std::function<void()>;
-void RecRegNewSyncStatSync(RecCallbackFunction callback);
diff --git a/src/records/RecRawStats.cc b/src/records/RecRawStats.cc
index 850c9fbc3c..e78667233d 100644
--- a/src/records/RecRawStats.cc
+++ b/src/records/RecRawStats.cc
@@ -22,7 +22,7 @@ Record statistics support
*/
#include "P_RecCore.h"
-#include "P_RecProcess.h"
+#include "records/RecProcess.h"
#include <string_view>
#include <list>