From 01656bfecdad87ee2b2e27250ad44bc1576aac00 Mon Sep 17 00:00:00 2001 From: JacksonEi Date: Mon, 20 Oct 2025 16:20:23 +0800 Subject: [PATCH 1/7] chore: tests using testing.B.Loop --- chain/state/statetree_test.go | 6 +++--- chain/types/electionproof_test.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/chain/state/statetree_test.go b/chain/state/statetree_test.go index c9f2748620c..25a0558826b 100644 --- a/chain/state/statetree_test.go +++ b/chain/state/statetree_test.go @@ -26,7 +26,7 @@ func BenchmarkStateTreeSet(b *testing.B) { b.ResetTimer() b.ReportAllocs() - for i := 0; i < b.N; i++ { + for b.Loop() { a, err := address.NewIDAddress(uint64(i)) if err != nil { b.Fatal(err) @@ -58,7 +58,7 @@ func BenchmarkStateTreeSetFlush(b *testing.B) { b.ResetTimer() b.ReportAllocs() - for i := 0; i < b.N; i++ { + for b.Loop() { a, err := address.NewIDAddress(uint64(i)) if err != nil { b.Fatal(err) @@ -214,7 +214,7 @@ func BenchmarkStateTree10kGetActor(b *testing.B) { b.ResetTimer() b.ReportAllocs() - for i := 0; i < b.N; i++ { + for b.Loop() { a, err := address.NewIDAddress(uint64(i % 10000)) if err != nil { b.Fatal(err) diff --git a/chain/types/electionproof_test.go b/chain/types/electionproof_test.go index 21385868ca2..f92706080bb 100644 --- a/chain/types/electionproof_test.go +++ b/chain/types/electionproof_test.go @@ -119,7 +119,7 @@ func BenchmarkWinCounts(b *testing.B) { b.ResetTimer() b.ReportAllocs() - for i := 0; i < b.N; i++ { + for b.Loop() { ep.VRFProof = []byte{byte(i), byte(i >> 8), byte(i >> 16), byte(i >> 24), byte(i >> 32)} j := ep.ComputeWinCount(power, totalPower) res += j From b2c71ca061432160a9503a3f16bc2f11bded3a69 Mon Sep 17 00:00:00 2001 From: JacksonEi Date: Mon, 20 Oct 2025 16:47:07 +0800 Subject: [PATCH 2/7] chore: fix statetree_test.go --- chain/state/statetree_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/chain/state/statetree_test.go b/chain/state/statetree_test.go index 25a0558826b..785446a945a 100644 --- a/chain/state/statetree_test.go +++ b/chain/state/statetree_test.go @@ -27,7 +27,7 @@ func BenchmarkStateTreeSet(b *testing.B) { b.ReportAllocs() for b.Loop() { - a, err := address.NewIDAddress(uint64(i)) + a, err := address.NewIDAddress(uint64(b.N)) if err != nil { b.Fatal(err) } @@ -35,7 +35,7 @@ func BenchmarkStateTreeSet(b *testing.B) { Balance: types.NewInt(1258812523), Code: builtin2.StorageMinerActorCodeID, Head: builtin2.AccountActorCodeID, - Nonce: uint64(i), + Nonce: uint64(b.N), }) if err != nil { b.Fatal(err) @@ -59,7 +59,7 @@ func BenchmarkStateTreeSetFlush(b *testing.B) { b.ReportAllocs() for b.Loop() { - a, err := address.NewIDAddress(uint64(i)) + a, err := address.NewIDAddress(uint64(b.N)) if err != nil { b.Fatal(err) } @@ -67,7 +67,7 @@ func BenchmarkStateTreeSetFlush(b *testing.B) { Balance: types.NewInt(1258812523), Code: builtin2.StorageMinerActorCodeID, Head: builtin2.AccountActorCodeID, - Nonce: uint64(i), + Nonce: uint64(b.N), }) if err != nil { b.Fatal(err) @@ -215,7 +215,7 @@ func BenchmarkStateTree10kGetActor(b *testing.B) { b.ReportAllocs() for b.Loop() { - a, err := address.NewIDAddress(uint64(i % 10000)) + a, err := address.NewIDAddress(uint64(b.N % 10000)) if err != nil { b.Fatal(err) } From 80929c6bb5db3637aa3f70615ec843db7f3202d1 Mon Sep 17 00:00:00 2001 From: JacksonEi Date: Mon, 20 Oct 2025 17:02:37 +0800 Subject: [PATCH 3/7] chore: fix electionproof_test.go --- chain/types/electionproof_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chain/types/electionproof_test.go b/chain/types/electionproof_test.go index f92706080bb..bd45cf2b68c 100644 --- a/chain/types/electionproof_test.go +++ b/chain/types/electionproof_test.go @@ -120,7 +120,7 @@ func BenchmarkWinCounts(b *testing.B) { b.ResetTimer() b.ReportAllocs() for b.Loop() { - ep.VRFProof = []byte{byte(i), byte(i >> 8), byte(i >> 16), byte(i >> 24), byte(i >> 32)} + ep.VRFProof = []byte{byte(b.N), byte(b.N >> 8), byte(b.N >> 16), byte(b.N >> 24), byte(b.N >> 32)} j := ep.ComputeWinCount(power, totalPower) res += j } From d534709b8a217120ba20c8ee63cff45366323ca2 Mon Sep 17 00:00:00 2001 From: JacksonEi Date: Mon, 20 Oct 2025 17:14:08 +0800 Subject: [PATCH 4/7] up changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 219eaad5f6b..fc43a29e107 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ - chore: update benchmark tests to use testing.B.Loop for improved performance ([filecoin-project/lotus#13385](https://github.com/filecoin-project/lotus/pull/13385)) - fix(eth): properly return vm error in all gas estimation methods ([filecoin-project/lotus#13389](https://github.com/filecoin-project/lotus/pull/13389)) - chore: all actor cmd support --actor ([filecoin-project/lotus#13391](https://github.com/filecoin-project/lotus/pull/13391)) +- chore: use testing.B.Loop for improved performance ([filecoin-project/lotus#13396](https://github.com/filecoin-project/lotus/pull/13396)) # Node and Miner v1.34.1 / 2025-09-15 From 32eaa6d36ab6356d1df5bf14fd309957d7f66958 Mon Sep 17 00:00:00 2001 From: JacksonEi Date: Tue, 21 Oct 2025 14:04:00 +0800 Subject: [PATCH 5/7] chore: tests using testing.B.Loop --- CHANGELOG.md | 2 +- chain/types/ethtypes/eth_types_test.go | 2 +- chain/types/types_test.go | 2 +- lib/shardedmutex/shardedmutex_test.go | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc43a29e107..3cff4c5b1df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ - chore(deps): update of quic-go to v0.54.1 and go-libp2p to v0.43.0 ([filecoin-project/lotus#13361](https://github.com/filecoin-project/lotus/pull/13361)) - feat(spcli): add a `deposit-margin-factor` option to `lotus-miner actor new` and `lotus-shed miner create` so the sent deposit still covers the on-chain requirement if it rises between lookup and execution - feat(cli): lotus evm deploy prints message CID ([filecoin-project/lotus#13378](https://github.com/filecoin-project/lotus/pull/13378)) -- chore: update benchmark tests to use testing.B.Loop for improved performance ([filecoin-project/lotus#13385](https://github.com/filecoin-project/lotus/pull/13385)) +- chore: update benchmark tests to use testing.B.Loop for improved performance ([filecoin-project/lotus#13385](https://github.com/filecoin-project/lotus/pull/13385))([filecoin-project/lotus#13396](https://github.com/filecoin-project/lotus/pull/13396)) - fix(eth): properly return vm error in all gas estimation methods ([filecoin-project/lotus#13389](https://github.com/filecoin-project/lotus/pull/13389)) - chore: all actor cmd support --actor ([filecoin-project/lotus#13391](https://github.com/filecoin-project/lotus/pull/13391)) - chore: use testing.B.Loop for improved performance ([filecoin-project/lotus#13396](https://github.com/filecoin-project/lotus/pull/13396)) diff --git a/chain/types/ethtypes/eth_types_test.go b/chain/types/ethtypes/eth_types_test.go index 36e0e24c996..d993c261d5b 100644 --- a/chain/types/ethtypes/eth_types_test.go +++ b/chain/types/ethtypes/eth_types_test.go @@ -643,7 +643,7 @@ func stringPtr(s string) *string { func BenchmarkEthHashFromCid(b *testing.B) { c := cid.MustParse("bafy2bzacedwviarjtjraqakob5pslltmuo5n3xev3nt5zylezofkbbv5jclyu") - for i := 0; i < b.N; i++ { + for b.Loop() { _, err := EthHashFromCid(c) if err != nil { b.Fatalf("Error in EthHashFromCid: %v", err) diff --git a/chain/types/types_test.go b/chain/types/types_test.go index 1056fc430e1..b6509bafe6f 100644 --- a/chain/types/types_test.go +++ b/chain/types/types_test.go @@ -33,7 +33,7 @@ func BenchmarkSerializeMessage(b *testing.B) { } b.ReportAllocs() - for i := 0; i < b.N; i++ { + for b.Loop() { _, err := m.Serialize() if err != nil { b.Fatal(err) diff --git a/lib/shardedmutex/shardedmutex_test.go b/lib/shardedmutex/shardedmutex_test.go index a7d5f7d1dfe..62161e3e930 100644 --- a/lib/shardedmutex/shardedmutex_test.go +++ b/lib/shardedmutex/shardedmutex_test.go @@ -122,7 +122,7 @@ func BenchmarkShardedMutex(b *testing.B) { } b.ResetTimer() - for i := 0; i < b.N; i++ { + for b.Loop() { sm.Lock(1) sm.Unlock(1) } @@ -151,7 +151,7 @@ func BenchmarkShardedMutexOf(b *testing.B) { } b.ResetTimer() - for i := 0; i < b.N; i++ { + for b.Loop() { sm.Lock(str2) sm.Unlock(str2) } From 2706446bbf9d053e4bf640f12f415cd4e7c7223e Mon Sep 17 00:00:00 2001 From: JacksonEi Date: Tue, 21 Oct 2025 14:09:27 +0800 Subject: [PATCH 6/7] chore: tests using testing.B.Loop --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3cff4c5b1df..9487b5e248f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,6 @@ - chore: update benchmark tests to use testing.B.Loop for improved performance ([filecoin-project/lotus#13385](https://github.com/filecoin-project/lotus/pull/13385))([filecoin-project/lotus#13396](https://github.com/filecoin-project/lotus/pull/13396)) - fix(eth): properly return vm error in all gas estimation methods ([filecoin-project/lotus#13389](https://github.com/filecoin-project/lotus/pull/13389)) - chore: all actor cmd support --actor ([filecoin-project/lotus#13391](https://github.com/filecoin-project/lotus/pull/13391)) -- chore: use testing.B.Loop for improved performance ([filecoin-project/lotus#13396](https://github.com/filecoin-project/lotus/pull/13396)) # Node and Miner v1.34.1 / 2025-09-15 From 7ca6e0c27a5d15ed0c5853e081322a4edea38518 Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Tue, 21 Oct 2025 21:22:37 +1300 Subject: [PATCH 7/7] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9487b5e248f..9a274881e5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +13,7 @@ - chore(deps): update of quic-go to v0.54.1 and go-libp2p to v0.43.0 ([filecoin-project/lotus#13361](https://github.com/filecoin-project/lotus/pull/13361)) - feat(spcli): add a `deposit-margin-factor` option to `lotus-miner actor new` and `lotus-shed miner create` so the sent deposit still covers the on-chain requirement if it rises between lookup and execution - feat(cli): lotus evm deploy prints message CID ([filecoin-project/lotus#13378](https://github.com/filecoin-project/lotus/pull/13378)) -- chore: update benchmark tests to use testing.B.Loop for improved performance ([filecoin-project/lotus#13385](https://github.com/filecoin-project/lotus/pull/13385))([filecoin-project/lotus#13396](https://github.com/filecoin-project/lotus/pull/13396)) +- chore: update benchmark tests to use testing.B.Loop for improved performance ([filecoin-project/lotus#13385](https://github.com/filecoin-project/lotus/pull/13385)) ([filecoin-project/lotus#13396](https://github.com/filecoin-project/lotus/pull/13396)) - fix(eth): properly return vm error in all gas estimation methods ([filecoin-project/lotus#13389](https://github.com/filecoin-project/lotus/pull/13389)) - chore: all actor cmd support --actor ([filecoin-project/lotus#13391](https://github.com/filecoin-project/lotus/pull/13391))