ethereum / go-ethereum

Go implementation of the Ethereum protocol
https://geth.ethereum.org
GNU Lesser General Public License v3.0
47.61k stars 20.16k forks source link

Investigate slow `386` test runs #27947

Closed holiman closed 1 year ago

holiman commented 1 year ago

On our appveyor CI runs, I compared the windows 386 vs amd64 test execution time. The ones below are not necessarily the most long-running packages, but the ones where the difference between the two architectures are the biggest.

We should investigate if there's anything we can do to improve these figures. In the case of crypto ops, it might just be the instruction set / width, but in other case (like protocols/snap), I find it hard to see why it 386 should be so much slower.

package GETH_ARCH=386 GETH_ARCH=amd64
github.com/ethereum/go-ethereum/trie 145.381s 71.389s
github.com/ethereum/go-ethereum/eth/protocols/snap 158.658s 83.165s
github.com/ethereum/go-ethereum/les/flowcontrol 16.828s 8.095s
github.com/ethereum/go-ethereum/core/state 26.940s 11.175s
github.com/ethereum/go-ethereum/les/vflux/server 30.735s 19.575s
github.com/ethereum/go-ethereum/core/vm 35.338s 4.463s
github.com/ethereum/go-ethereum/rpc 39.018s 22.301s
github.com/ethereum/go-ethereum/core/txpool/legacypool 61.326s 26.320s
github.com/ethereum/go-ethereum/cmd/geth 70.992s 31.339s
github.com/ethereum/go-ethereum/crypto/kzg4844 83.423s 10.960s
github.com/ethereum/go-ethereum/crypto/bls12381 9.750s 1.179s
holiman commented 1 year ago

For the github.com/ethereum/go-ethereum/crypto/kzg4844, the evaluateLagrangePolynomial falls back into gnark-crypto, which has element_ops_amd64and element_mul_amd64 in assembly, but falls back to element_ops_purego for the 386 version.

holiman commented 1 year ago

For core/vm, here are the big differences when I run locally, with GOARCH=386 vs normal: GOARCH=386:

TestPrecompiledBLS12381G2MultiExp (12.08s)
TestPrecompiledBLS12381Pairing (12.13s)
TestPrecompiledBLS12381MapG2 (5.03s)

GOARCH=amd64:

TestPrecompiledBLS12381G2MultiExp (1.37s)
TestPrecompiledBLS12381Pairing (1.36s)
TestPrecompiledBLS12381MapG2 (0.44s)

These are tests for an eip which is not active.