Skip to content

Commit c9a73ad

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).
1 parent 1bce2b8 commit c9a73ad

File tree

5 files changed

+18
-10
lines changed

5 files changed

+18
-10
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: 7 additions & 5 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.
@@ -245,16 +247,16 @@ void chartsdata_refresh(void) {
245247
data[CHARTS_TOTAL_LLOPW] = totalOpsWrite;
246248
data[CHARTS_REPL] = replications + gReplicator.getStats();
247249

248-
HddStats::operationStats(&opsCreate, &opsDelete, &opsUpdateVersion,
249-
&opsDuplicate, &opsTruncate, &opsDupTrunc,
250-
&opsTest);
250+
HddStats::operationStats(&opsCreate, &opsDelete, &opsUpdateVersion, &opsDuplicate, &opsTruncate,
251+
&opsDupTrunc, &opsTest, &opsGCPurge);
251252
data[CHARTS_CREATE] = opsCreate;
252253
data[CHARTS_DELETE] = opsDelete;
253254
data[CHARTS_VERSION] = opsUpdateVersion;
254255
data[CHARTS_DUPLICATE] = opsDuplicate;
255256
data[CHARTS_TRUNCATE] = opsTruncate;
256257
data[CHARTS_DUPTRUNC] = opsDupTrunc;
257258
data[CHARTS_TEST] = opsTest;
259+
data[CHARTS_GC_PURGE] = opsGCPurge;
258260

259261
charts_add(data, eventloop_time() - SECONDS_IN_ONE_MINUTE);
260262
}

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)