From d7631fb997028efea91c7733cbe5ae608d8b8a76 Mon Sep 17 00:00:00 2001 From: Anton Evangelatov Date: Fri, 26 Jun 2020 14:09:58 +0200 Subject: [PATCH] basic timers and counters --- lotus-soup/baseline.go | 10 ++++++++++ lotus-soup/common_roles.go | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/lotus-soup/baseline.go b/lotus-soup/baseline.go index df0e195b2..6349c79e5 100644 --- a/lotus-soup/baseline.go +++ b/lotus-soup/baseline.go @@ -98,6 +98,7 @@ func runBaselineClient(t *TestEnvironment) error { t.RecordMessage("file cid: %s", fcid) // start deal + t1 := time.Now() deal := startDeal(ctx, minerAddr.ActorAddr, client, fcid) t.RecordMessage("started deal: %s", deal) @@ -106,11 +107,13 @@ func runBaselineClient(t *TestEnvironment) error { t.RecordMessage("waiting for deal to be sealed") waitDealSealed(t, ctx, client, deal) + t.D().ResettingHistogram("deal.sealed").Update(int64(time.Since(t1))) carExport := true t.RecordMessage("trying to retrieve %s", fcid) retrieveData(t, ctx, err, client, fcid, carExport, data) + t.D().ResettingHistogram("deal.retrieved").Update(int64(time.Since(t1))) t.SyncClient.MustSignalEntry(ctx, stateStopMining) @@ -164,10 +167,15 @@ loop: } func retrieveData(t *TestEnvironment, ctx context.Context, err error, client api.FullNode, fcid cid.Cid, carExport bool, data []byte) { + t1 := time.Now() offers, err := client.ClientFindData(ctx, fcid) if err != nil { panic(err) } + for _, o := range offers { + t.D().Counter(fmt.Sprintf("find-data.offer.%s", o.Miner)).Inc(1) + } + t.D().ResettingHistogram("find-data").Update(int64(time.Since(t1))) if len(offers) < 1 { panic("no offers") @@ -188,10 +196,12 @@ func retrieveData(t *TestEnvironment, ctx context.Context, err error, client api Path: filepath.Join(rpath, "ret"), IsCAR: carExport, } + t1 = time.Now() err = client.ClientRetrieve(ctx, offers[0].Order(caddr), ref) if err != nil { panic(err) } + t.D().ResettingHistogram("retrieve-data").Update(int64(time.Since(t1))) rdata, err := ioutil.ReadFile(filepath.Join(rpath, "ret")) if err != nil { diff --git a/lotus-soup/common_roles.go b/lotus-soup/common_roles.go index ee1a4d4df..df47f3aee 100644 --- a/lotus-soup/common_roles.go +++ b/lotus-soup/common_roles.go @@ -6,6 +6,7 @@ import ( "math/rand" "time" + "github.com/filecoin-project/lotus/build" "github.com/testground/sdk-go/sync" ) @@ -28,6 +29,9 @@ func runMiner(t *TestEnvironment) error { return err } + t.RecordMessage("block delay: %v", build.BlockDelay) + t.D().Gauge("miner.block-delay").Update(build.BlockDelay) + ctx := context.Background() clients := t.IntParam("clients") @@ -50,6 +54,8 @@ func runMiner(t *TestEnvironment) error { time.Sleep(time.Duration(100 + rand.Intn(int(100*time.Millisecond)))) err := miner.MineOne(ctx, func(bool) { + + t.D().Counter("miner.mine").Inc(1) // after a block is mined }) if err != nil {