Skip to content

Conversation

@jsvisa
Copy link
Contributor

@jsvisa jsvisa commented Jul 7, 2025

ref #32059

Here we use a [16]array of path map to store all the trienodes indexes, then we can split the large storage trienodes into 16 goroutines to do lock-free updates.

The below charts are generated with geth on hoodi network with full sync

full sync block height

image
  • green is master
  • yellow is this branch

pathdb lookup latency

image

Results:

  1. The totally block inserting time is similar
  2. The time of (un)indexing in this branch is 3 times more than the master branch.

```
go test ./triedb/pathdb/ -bench BenchmarkAddNodes
```

> old

```
goos: linux
goarch: amd64
pkg: github.com/ethereum/go-ethereum/triedb/pathdb
cpu: AMD Ryzen 7 5700G with Radeon Graphics
BenchmarkAddNodes/Small-100-accounts-10-nodes-16                    3624            308151 ns/op         1138262 B/op       1236 allocs/op
BenchmarkAddNodes/Medium-500-accounts-20-nodes-16                    738           2216662 ns/op        10793841 B/op      10352 allocs/op
BenchmarkAddNodes/Large-2000-accounts-40-nodes-16                     44          27227664 ns/op        92272295 B/op      80897 allocs/op
BenchmarkAddNodes/XLarge-5000-accounts-50-nodes-16                    13          92061992 ns/op        328729686 B/op    252497 allocs/op
PASS
ok      github.com/ethereum/go-ethereum/triedb/pathdb   20.772s
```

> new

```
goos: linux
goarch: amd64
pkg: github.com/ethereum/go-ethereum/triedb/pathdb
cpu: AMD Ryzen 7 5700G with Radeon Graphics
BenchmarkAddNodes/Small-100-accounts-10-nodes-16                    6706            232594 ns/op          673550 B/op       1215 allocs/op
BenchmarkAddNodes/Medium-500-accounts-20-nodes-16                    804           1292732 ns/op         5910825 B/op      10328 allocs/op
BenchmarkAddNodes/Large-2000-accounts-40-nodes-16                     60          20907603 ns/op        53871128 B/op      80873 allocs/op
BenchmarkAddNodes/XLarge-5000-accounts-50-nodes-16                    13          78489762 ns/op        208748856 B/op    252475 allocs/op
PASS
ok      github.com/ethereum/go-ethereum/triedb/pathdb   19.420s
```

Signed-off-by: jsvisa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants