Skip to content

Commit 80cf4ee

Browse files
committed
core/rawdb: add bench for decoding into rlpLogs
1 parent 1ea7608 commit 80cf4ee

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

core/rawdb/accessors_chain.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,8 @@ type storedReceiptRLP struct {
673673
}
674674

675675
// ReceiptLogs is a barebone version of ReceiptForStorage which only keeps
676-
// the list of logs.
676+
// the list of logs. When decoding a stored receipt into this object we
677+
// avoid creating the bloom filter.
677678
type receiptLogs struct {
678679
Logs []*types.Log
679680
}

core/rawdb/accessors_chain_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,3 +857,29 @@ func TestDeriveLogFields(t *testing.T) {
857857
}
858858
}
859859
}
860+
861+
func BenchmarkDecodeRLPLogs(b *testing.B) {
862+
// Encoded receipts from block 0x14ee094309fbe8f70b65f45ebcc08fb33f126942d97464aad5eb91cfd1e2d269
863+
buf, err := ioutil.ReadFile("testdata/stored_receipts.bin")
864+
if err != nil {
865+
b.Fatal(err)
866+
}
867+
b.Run("ReceiptForStorage", func(b *testing.B) {
868+
b.ReportAllocs()
869+
var r []*types.ReceiptForStorage
870+
for i := 0; i < b.N; i++ {
871+
if err := rlp.DecodeBytes(buf, &r); err != nil {
872+
b.Fatal(err)
873+
}
874+
}
875+
})
876+
b.Run("rlpLogs", func(b *testing.B) {
877+
b.ReportAllocs()
878+
var r []*receiptLogs
879+
for i := 0; i < b.N; i++ {
880+
if err := rlp.DecodeBytes(buf, &r); err != nil {
881+
b.Fatal(err)
882+
}
883+
}
884+
})
885+
}
97.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)