From e7f7ee19bc665f3ec993be2c4c2c3e9d7d187192 Mon Sep 17 00:00:00 2001 From: Hillium Date: Mon, 31 Aug 2020 11:19:08 +0800 Subject: [PATCH 1/3] summary: add real time cost to log collector Signed-off-by: Hillium --- pkg/restore/client.go | 1 + pkg/restore/import.go | 4 ++-- pkg/summary/collector.go | 5 ++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/restore/client.go b/pkg/restore/client.go index 0b96c60c0..49162842f 100644 --- a/pkg/restore/client.go +++ b/pkg/restore/client.go @@ -755,6 +755,7 @@ func (rc *Client) GoValidateChecksum( wg.Wait() elapsed := time.Since(start) summary.CollectDuration("restore checksum", elapsed) + summary.CollectSuccessUnit("table checksumed", 1, elapsed) outCh <- struct{}{} close(outCh) }() diff --git a/pkg/restore/import.go b/pkg/restore/import.go index a4d3dde8c..c74116032 100644 --- a/pkg/restore/import.go +++ b/pkg/restore/import.go @@ -332,9 +332,9 @@ func (importer *FileImporter) Import( zap.Error(errIngest)) return errIngest } - summary.CollectSuccessUnit(summary.TotalKV, 1, file.TotalKvs) - summary.CollectSuccessUnit(summary.TotalBytes, 1, file.TotalBytes) } + summary.CollectSuccessUnit(summary.TotalKV, 1, file.TotalKvs) + summary.CollectSuccessUnit(summary.TotalBytes, 1, file.TotalBytes) return nil }, newImportSSTBackoffer()) return err diff --git a/pkg/summary/collector.go b/pkg/summary/collector.go index a8b7e2427..fcd8f41e8 100644 --- a/pkg/summary/collector.go +++ b/pkg/summary/collector.go @@ -77,6 +77,7 @@ type logCollector struct { ints map[string]int uints map[string]uint64 successStatus bool + startTime time.Time log logFunc } @@ -92,6 +93,7 @@ func newLogCollector(log logFunc) LogCollector { ints: make(map[string]int), uints: make(map[string]uint64), log: log, + startTime: time.Now(), } } @@ -189,7 +191,8 @@ func (tc *logCollector) Summary(name string) { for _, cost := range tc.successCosts { totalCost += cost } - msg += fmt.Sprintf(", total take(s): %.2f", totalCost.Seconds()) + msg += fmt.Sprintf(", total take(TiKV service time): %s", totalCost) + msg += fmt.Sprintf(", total take(real time): %s", time.Since(tc.startTime)) for name, data := range tc.successData { if name == TotalBytes { fData := float64(data) / 1024 / 1024 From 208a92bd2dcb391ad9430e212d6dcd9c668ba781 Mon Sep 17 00:00:00 2001 From: Hillium Date: Tue, 1 Sep 2020 11:00:39 +0800 Subject: [PATCH 2/3] summary: rename TiKV service time to $name time Signed-off-by: Hillium --- pkg/summary/collector.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/summary/collector.go b/pkg/summary/collector.go index fcd8f41e8..20a2bc2d1 100644 --- a/pkg/summary/collector.go +++ b/pkg/summary/collector.go @@ -191,7 +191,7 @@ func (tc *logCollector) Summary(name string) { for _, cost := range tc.successCosts { totalCost += cost } - msg += fmt.Sprintf(", total take(TiKV service time): %s", totalCost) + msg += fmt.Sprintf(", total take(%s time): %s", name, totalCost) msg += fmt.Sprintf(", total take(real time): %s", time.Since(tc.startTime)) for name, data := range tc.successData { if name == TotalBytes { From 7ba330f35a68e152e7df33f1b1ca9853c4842f4e Mon Sep 17 00:00:00 2001 From: Hillium Date: Tue, 1 Sep 2020 17:01:37 +0800 Subject: [PATCH 3/3] restore: fix a typo Signed-off-by: Hillium --- pkg/restore/client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/restore/client.go b/pkg/restore/client.go index 49162842f..d62a2a9fb 100644 --- a/pkg/restore/client.go +++ b/pkg/restore/client.go @@ -755,7 +755,7 @@ func (rc *Client) GoValidateChecksum( wg.Wait() elapsed := time.Since(start) summary.CollectDuration("restore checksum", elapsed) - summary.CollectSuccessUnit("table checksumed", 1, elapsed) + summary.CollectSuccessUnit("table checksum", 1, elapsed) outCh <- struct{}{} close(outCh) }()