Skip to content

Commit d5b77ea

Browse files
committed
feat(monitoring): add GC stats to CS charts
This commit introduces a chunkserver-side feature to display Garbage Collector(GC) deletions per minute in the CGI chart of the chunkserver(CS). Apply formatting to function" to chartsdata_refresh function. Signed-off-by: GigaCronos <jorge.cabrera@leil.io> fa
1 parent 4264de9 commit d5b77ea

File tree

5 files changed

+25
-21
lines changed

5 files changed

+25
-21
lines changed

src/cgi/sfs.cgi.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3235,6 +3235,7 @@ if "CC" in sectionset:
32353235
(21, 'create', 'number of chunk creations per minute'),
32363236
(22, 'delete', 'number of chunk deletions per minute'),
32373237
(27, 'tests', 'number of chunk tests per minute'),
3238+
(31, 'gcpurge', 'number of chunk purged by GC per minute'),
32383239
)
32393240
servers = []
32403241

src/chunkserver/chartsdata.cc

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@
7575
#define CHARTS_CHUNKIOJOBS 28
7676
#define CHARTS_CHUNKOPJOBS 29
7777
#define CHARTS_MEMORY 30
78+
#define CHARTS_GC_PURGE 31
7879

79-
#define CHARTS_NUMBER 31
80+
#define CHARTS_NUMBER 32
8081

8182
const unsigned long kLinuxMaxrssSize = 1024UL;
8283

@@ -113,6 +114,7 @@ const unsigned long kLinuxMaxrssSize = 1024UL;
113114
{"chunkiojobs" ,CHARTS_MODE_MAX,0,CHARTS_SCALE_NONE , 1, 1}, \
114115
{"chunkopjobs" ,CHARTS_MODE_MAX,0,CHARTS_SCALE_NONE , 1, 1}, \
115116
{"memory" ,CHARTS_MODE_MAX,0,CHARTS_SCALE_NONE , 1, 1}, \
117+
{"gcpurge" ,CHARTS_MODE_ADD,0,CHARTS_SCALE_NONE , 1, 1}, \
116118
{NULL ,0 ,0,0 , 0, 0} \
117119
};
118120

@@ -165,7 +167,7 @@ void chartsdata_refresh(void) {
165167
uint64_t bytesIn, bytesOut, totalBytesRead, totalBytesWrite;
166168
uint32_t opsRead, opsWrite, totalOpsRead, totalOpsWrite, replications = 0;
167169
uint32_t opsCreate, opsDelete, opsUpdateVersion, opsDuplicate, opsTruncate;
168-
uint32_t opsDupTrunc, opsTest;
170+
uint32_t opsDupTrunc, opsTest, opsGCPurge;
169171
uint32_t maxChunkServerJobsCount, maxMasterJobsCount;
170172

171173
// Timer runs only when the process is executing.
@@ -177,12 +179,10 @@ void chartsdata_refresh(void) {
177179

178180
uint32_t userTimeMicroSeconds, procTimeMicroSeconds;
179181

180-
for (auto i = 0; i < CHARTS_NUMBER; ++i) {
181-
data[i] = 0;
182-
}
182+
for (auto i = 0; i < CHARTS_NUMBER; ++i) { data[i] = 0; }
183183

184-
setitimer(ITIMER_VIRTUAL, &it_set, &userTime); // user time
185-
setitimer(ITIMER_PROF, &it_set, &procTime); // user time + system time
184+
setitimer(ITIMER_VIRTUAL, &it_set, &userTime); // user time
185+
setitimer(ITIMER_PROF, &it_set, &procTime); // user time + system time
186186

187187
// on fucken linux timers can go backward !!!
188188
if (userTime.it_value.tv_sec <= 999) {
@@ -223,18 +223,16 @@ void chartsdata_refresh(void) {
223223
data[CHARTS_CSCONNIN] = 0;
224224
data[CHARTS_CSCONNOUT] = 0;
225225

226-
networkStats(&bytesIn, &bytesOut, &opsRead, &opsWrite,
227-
&maxChunkServerJobsCount);
226+
networkStats(&bytesIn, &bytesOut, &opsRead, &opsWrite, &maxChunkServerJobsCount);
228227
data[CHARTS_CSSERVIN] = bytesIn;
229228
data[CHARTS_CSSERVOUT] = bytesOut;
230229
data[CHARTS_CHUNKIOJOBS] = maxChunkServerJobsCount;
231230
data[CHARTS_HLOPR] = opsRead;
232231
data[CHARTS_HLOPW] = opsWrite;
233232

234-
HddStats::stats(HddStats::statsReport(
235-
&bytesIn, &bytesOut, &opsRead, &opsWrite, &totalBytesRead,
236-
&totalBytesWrite, &totalOpsRead, &totalOpsWrite,
237-
data + CHARTS_TOTAL_RTIME, data + CHARTS_TOTAL_WTIME));
233+
HddStats::stats(HddStats::statsReport(&bytesIn, &bytesOut, &opsRead, &opsWrite, &totalBytesRead,
234+
&totalBytesWrite, &totalOpsRead, &totalOpsWrite,
235+
data + CHARTS_TOTAL_RTIME, data + CHARTS_TOTAL_WTIME));
238236
data[CHARTS_OVERHEAD_BYTESR] = bytesIn;
239237
data[CHARTS_OVERHEAD_BYTESW] = bytesOut;
240238
data[CHARTS_OVERHEAD_LLOPR] = opsRead;
@@ -245,16 +243,16 @@ void chartsdata_refresh(void) {
245243
data[CHARTS_TOTAL_LLOPW] = totalOpsWrite;
246244
data[CHARTS_REPL] = replications + gReplicator.getStats();
247245

248-
HddStats::operationStats(&opsCreate, &opsDelete, &opsUpdateVersion,
249-
&opsDuplicate, &opsTruncate, &opsDupTrunc,
250-
&opsTest);
246+
HddStats::operationStats(&opsCreate, &opsDelete, &opsUpdateVersion, &opsDuplicate, &opsTruncate,
247+
&opsDupTrunc, &opsTest, &opsGCPurge);
251248
data[CHARTS_CREATE] = opsCreate;
252249
data[CHARTS_DELETE] = opsDelete;
253250
data[CHARTS_VERSION] = opsUpdateVersion;
254251
data[CHARTS_DUPLICATE] = opsDuplicate;
255252
data[CHARTS_TRUNCATE] = opsTruncate;
256253
data[CHARTS_DUPTRUNC] = opsDupTrunc;
257254
data[CHARTS_TEST] = opsTest;
255+
data[CHARTS_GC_PURGE] = opsGCPurge;
258256

259257
charts_add(data, eventloop_time() - SECONDS_IN_ONE_MINUTE);
260258
}

src/chunkserver/chunkserver-common/chunk_trash_manager_impl.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "chunkserver-common/chunk_trash_manager_impl.h"
2626
#include "config/cfg.h"
2727
#include "errors/saunafs_error_codes.h"
28+
#include "hdd_stats.h"
2829
#include "slogger/slogger.h"
2930

3031
namespace fs = std::filesystem;
@@ -161,6 +162,7 @@ void ChunkTrashManagerImpl::removeTrashFiles(
161162
for (const auto &[diskPath, fileEntries] : filesToRemove) {
162163
for (const auto &fileEntry : fileEntries) {
163164
if (removeFileFromTrash(fileEntry.second) != SAUNAFS_STATUS_OK) { continue; }
165+
HddStats::gStatsOperationsGCPurge++;
164166
getTrashIndex().remove(fileEntry.first, fileEntry.second, diskPath);
165167
}
166168
}

src/chunkserver/chunkserver-common/hdd_stats.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "common/platform.h"
2020

2121
#include "chunkserver-common/hdd_stats.h"
22+
#include <cstdint>
2223

2324
#include "chunkserver-common/disk_interface.h"
2425
#include "devtools/TracePrinter.h"
@@ -83,10 +84,9 @@ void stats(statsReport report) {
8384
*report.totalWriteTime = gStatsTotalTimeWrite.exchange(0);
8485
}
8586

86-
void operationStats(uint32_t *opsCreate, uint32_t *opsDelete,
87-
uint32_t *opsUpdateVersion, uint32_t *opsDuplicate,
88-
uint32_t *opsTruncate, uint32_t *opsDupTrunc,
89-
uint32_t *opsTest) {
87+
void operationStats(uint32_t *opsCreate, uint32_t *opsDelete, uint32_t *opsUpdateVersion,
88+
uint32_t *opsDuplicate, uint32_t *opsTruncate, uint32_t *opsDupTrunc,
89+
uint32_t *opsTest, uint32_t *opsGCPurge) {
9090
TRACETHIS();
9191
*opsCreate = gStatsOperationsCreate.exchange(0);
9292
*opsDelete = gStatsOperationsDelete.exchange(0);
@@ -95,6 +95,7 @@ void operationStats(uint32_t *opsCreate, uint32_t *opsDelete,
9595
*opsDuplicate = gStatsOperationsDuplicate.exchange(0);
9696
*opsTruncate = gStatsOperationsTruncate.exchange(0);
9797
*opsDupTrunc = gStatsOperationsDupTrunc.exchange(0);
98+
*opsGCPurge = gStatsOperationsGCPurge.exchange(0);
9899
}
99100

100101
void overheadRead(uint32_t size) {

src/chunkserver/chunkserver-common/hdd_stats.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ inline std::atomic<uint32_t> gStatsOperationsDuplicate(0);
5656
inline std::atomic<uint32_t> gStatsOperationsTruncate(0);
5757
inline std::atomic<uint32_t> gStatsOperationsDupTrunc(0);
5858

59+
inline std::atomic<uint32_t> gStatsOperationsGCPurge(0);
60+
5961
struct statsReport {
6062
statsReport(uint64_t *overBytesRead, uint64_t *overBytesWrite,
6163
uint32_t *overOpsRead, uint32_t *overOpsWrite,
@@ -99,7 +101,7 @@ void stats(statsReport report);
99101
void operationStats(uint32_t *opsCreate, uint32_t *opsDelete,
100102
uint32_t *opsUpdateVersion, uint32_t *opsDuplicate,
101103
uint32_t *opsTruncate, uint32_t *opsDupTrunc,
102-
uint32_t *opsTest);
104+
uint32_t *opsTest, uint32_t *opsGCPurge);
103105

104106
void overheadRead(uint32_t size);
105107
void overheadWrite(uint32_t size);

0 commit comments

Comments
 (0)