fix(volume): expose the COW read counters in cut responses

This commit is contained in:
pingqiu committed 2026-11-19 20:16:35 -08:00
1 parent ed5d4369e7
commit 77fc4e5c12
3 files changed
+54 -42

No files matched your search

+46 -42
View File
@@ -55,52 +55,56 @@ type ChunkCutResponse struct {
// mirrors storage.ChunkCutStats field for field (a test keeps the two in
// step); every duration is in nanoseconds.
type ChunkCutStatsBody struct {
COWSavedChunks int `json:"cowSavedChunks"`
COWSaveNs int64 `json:"cowSaveNs"`
COWWaitNs int64 `json:"cowWaitNs"`
BarrierPauseNs int64 `json:"barrierPauseNs"`
LockWaitNs int64 `json:"lockWaitNs"`
SyncNs int64 `json:"syncNs"`
CopyNs int64 `json:"copyNs"`
CandidateChunks int `json:"candidateChunks"`
UploadedChunks int `json:"uploadedChunks"`
UploadedBytes int64 `json:"uploadedBytes"`
ZeroedChunks int `json:"zeroedChunks"`
UnchangedChunks int `json:"unchangedChunks"`
UploadNs int64 `json:"uploadNs"`
CASNs int64 `json:"casNs"`
CASResult string `json:"casResult"`
TotalNs int64 `json:"totalNs"`
StageRounds int `json:"stageRounds"`
StagedChunks int `json:"stagedChunks"`
StagedChunksUsed int `json:"stagedChunksUsed"`
BarrierCopyChunks int `json:"barrierCopyChunks"`
BarrierOverBound bool `json:"barrierOverBound"`
COWWALReadAttempts uint64 `json:"cowWALReadAttempts"`
COWLocalReadNs int64 `json:"cowLocalReadNs"`
COWSavedChunks int `json:"cowSavedChunks"`
COWSaveNs int64 `json:"cowSaveNs"`
COWWaitNs int64 `json:"cowWaitNs"`
BarrierPauseNs int64 `json:"barrierPauseNs"`
LockWaitNs int64 `json:"lockWaitNs"`
SyncNs int64 `json:"syncNs"`
CopyNs int64 `json:"copyNs"`
CandidateChunks int `json:"candidateChunks"`
UploadedChunks int `json:"uploadedChunks"`
UploadedBytes int64 `json:"uploadedBytes"`
ZeroedChunks int `json:"zeroedChunks"`
UnchangedChunks int `json:"unchangedChunks"`
UploadNs int64 `json:"uploadNs"`
CASNs int64 `json:"casNs"`
CASResult string `json:"casResult"`
TotalNs int64 `json:"totalNs"`
StageRounds int `json:"stageRounds"`
StagedChunks int `json:"stagedChunks"`
StagedChunksUsed int `json:"stagedChunksUsed"`
BarrierCopyChunks int `json:"barrierCopyChunks"`
BarrierOverBound bool `json:"barrierOverBound"`
}
func cutStatsBody(s storage.ChunkCutStats) ChunkCutStatsBody {
return ChunkCutStatsBody{
BarrierPauseNs: s.BarrierPauseNs,
LockWaitNs: s.LockWaitNs,
SyncNs: s.SyncNs,
CopyNs: s.CopyNs,
COWSavedChunks: s.COWSavedChunks,
COWSaveNs: s.COWSaveNs,
COWWaitNs: s.COWWaitNs,
CandidateChunks: s.CandidateChunks,
UploadedChunks: s.UploadedChunks,
UploadedBytes: s.UploadedBytes,
ZeroedChunks: s.ZeroedChunks,
UnchangedChunks: s.UnchangedChunks,
UploadNs: s.UploadNs,
CASNs: s.CASNs,
CASResult: s.CASResult,
TotalNs: s.TotalNs,
StageRounds: s.StageRounds,
StagedChunks: s.StagedChunks,
StagedChunksUsed: s.StagedChunksUsed,
BarrierCopyChunks: s.BarrierCopyChunks,
BarrierOverBound: s.BarrierOverBound,
COWWALReadAttempts: s.COWWALReadAttempts,
COWLocalReadNs: s.COWLocalReadNs,
BarrierPauseNs: s.BarrierPauseNs,
LockWaitNs: s.LockWaitNs,
SyncNs: s.SyncNs,
CopyNs: s.CopyNs,
COWSavedChunks: s.COWSavedChunks,
COWSaveNs: s.COWSaveNs,
COWWaitNs: s.COWWaitNs,
CandidateChunks: s.CandidateChunks,
UploadedChunks: s.UploadedChunks,
UploadedBytes: s.UploadedBytes,
ZeroedChunks: s.ZeroedChunks,
UnchangedChunks: s.UnchangedChunks,
UploadNs: s.UploadNs,
CASNs: s.CASNs,
CASResult: s.CASResult,
TotalNs: s.TotalNs,
StageRounds: s.StageRounds,
StagedChunks: s.StagedChunks,
StagedChunksUsed: s.StagedChunksUsed,
BarrierCopyChunks: s.BarrierCopyChunks,
BarrierOverBound: s.BarrierOverBound,
}
}
@@ -168,6 +168,8 @@ func TestChunkCutStatsBody_MirrorsTheLayerStats(t *testing.T) {
switch f := v.Field(i); f.Kind() {
case reflect.Int, reflect.Int64:
f.SetInt(int64(i + 1))
case reflect.Uint64:
f.SetUint(uint64(i + 1))
case reflect.String:
f.SetString("s")
case reflect.Bool:
@@ -19,6 +19,8 @@ func TestChunkCutStatsBody_ExposesCOWCounters(t *testing.T) {
{"COWSavedChunks", "cowSavedChunks", 31},
{"COWSaveNs", "cowSaveNs", 47},
{"COWWaitNs", "cowWaitNs", 59},
{"COWWALReadAttempts", "cowWALReadAttempts", 61},
{"COWLocalReadNs", "cowLocalReadNs", 67},
}
value := reflect.ValueOf(&stats).Elem()
for _, field := range fields {
@@ -27,6 +29,10 @@ func TestChunkCutStatsBody_ExposesCOWCounters(t *testing.T) {
t.Errorf("RED: storage cut stats lack %s", field.goName)
continue
}
if target.Kind() == reflect.Uint64 {
target.SetUint(uint64(field.value))
continue
}
if target.Kind() != reflect.Int && target.Kind() != reflect.Int64 {
t.Errorf("counter %s has unexpected kind %s", field.goName, target.Kind())
continue