fix(tool): print stat log for remote cache test tool

with:#1000275887

Signed-off-by: clinx <chenlin1@oppo.com>
(cherry picked from commit 32641daf6d)
This commit is contained in:
clinx 2025-08-12 10:05:06 +08:00 committed by chihe
parent 62eece5dc5
commit b52dc796cf
2 changed files with 18 additions and 5 deletions

View File

@ -186,7 +186,10 @@ func (rc *RemoteCacheClient) refreshWithRecover() (panicErr error) {
refreshLatency := time.NewTimer(0)
defer refreshLatency.Stop()
var err error
var (
err error
notNew bool
)
for {
select {
case <-rc.stopC:
@ -199,8 +202,12 @@ func (rc *RemoteCacheClient) refreshWithRecover() (panicErr error) {
}
}
case <-refreshLatency.C:
if err = rc.UpdateFlashGroups(); err != nil {
log.LogErrorf("updateFlashGroups err: %v", err)
if notNew {
if err = rc.UpdateFlashGroups(); err != nil {
log.LogErrorf("updateFlashGroups err: %v", err)
}
} else {
notNew = true
}
rc.refreshHostLatency()
refreshLatency.Reset(RefreshHostLatencyInterval)

View File

@ -25,6 +25,7 @@ import (
"github.com/cubefs/cubefs/tool/remotecache-benchmark/storage"
"github.com/cubefs/cubefs/util"
"github.com/cubefs/cubefs/util/bytespool"
"github.com/cubefs/cubefs/util/stat"
"github.com/google/uuid"
)
@ -91,6 +92,10 @@ func NewBenchmarkTester(dataDir, hddBase, nvmeBase string, verify bool, master s
if err != nil {
fmt.Printf("\nCreate a remote cache Tester failed:%v\n", err)
}
_, err = stat.NewStatistic("/tmp/cfs", "remoteCacheClient", int64(stat.DefaultStatLogSize), stat.DefaultTimeOutUs, true)
if err != nil {
fmt.Printf("\nCreate a remote cache stat log failed:%v\n", err)
}
}
return tester
@ -197,8 +202,8 @@ func ensureAbsolutePath(path string) string {
func main() {
dataDir := flag.String("data", "./test_data", "Test data directory")
totalSizeGB := flag.Int("size", 100, "Total size of test data (GB)")
genConcurrency := flag.Int("gen-concurrency", runtime.NumCPU()*8, "Number of concurrent data generation processes")
concurrency := flag.Int("concurrency", runtime.NumCPU()*4, "Number of concurrent requests")
genConcurrency := flag.Int("gen-concurrency", util.Max(2, int(float64(runtime.NumCPU())*0.6)), "Number of concurrent data generation processes")
concurrency := flag.Int("concurrency", util.Max(2, int(float64(runtime.NumCPU())*0.6)), "Number of concurrent requests")
needGenerate := flag.Bool("need-generate", false, "Generate test data")
hddBase := flag.String("hdd", "", "HDD storage directory")
nvmeBase := flag.String("nvme", "", "NVME storage directory")
@ -270,6 +275,7 @@ func (t *BenchmarkTester) Stop() {
if t.cacheStorage != nil {
t.cacheStorage.Stop()
}
stat.WriteStat()
}
func (t *BenchmarkTester) RunPutBenchmark(ctx context.Context, concurrency int) {