Skip to content

Conversation

cuiweixie
Copy link
Contributor

goos: darwin
goarch: arm64
pkg: github.com/ethereum/go-ethereum/p2p/enode
cpu: Apple M1 Pro
           │   old.txt    │               new.txt               │
           │    sec/op    │   sec/op     vs base                │
DistCmp-10   12.225n ± 1%   2.772n ± 3%  -77.32% (p=0.000 n=10)

fjl and others added 2 commits October 13, 2025 14:17
Refactor DistCmp to improve distance comparison logic.
@fjl fjl changed the title p2p/enode: opt DistCmp p2p/enode: optimize DistCmp Oct 13, 2025
@fjl
Copy link
Contributor

fjl commented Oct 13, 2025

Hey @cuiweixie, I've changed this PR and your other one to remove extra variables. They are not necessary, since the length of type ID is constant (it is an array type), and thus all arithmetic like len(a)+8 will be performed at compile time.

@fjl fjl merged commit b87581f into ethereum:master Oct 13, 2025
6 of 7 checks passed
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