[ethereum/go-ethereum] consensus/ethash: use DAGs for remote mining, generate async (#17405)

Currently remote mining uses ethash verification caches. As such, when a node starts mining and remote mining send in `submitWork` requests, it takes the following processing times:

* Initial run with no pre-generated cache: 700 milliseconds
* Initial run with pre-generated cache from disk: 8 milliseconds
* Subsequent runs: ~6-7 milliseconds

it’s important to know that the caches are actually simulating the 2-4GB mining DAG by generating the needed data slots on the fly in memory. For individual blocks being imported, that is fine. However, the many Keccak256 ops can have a significant performance impact if we’re doing verification calls non-stop (i.e. a remote miner scenario).

A better approach for remote mining is to use the verification cache initially, but generate the mining DAG in the background and switch over to that. This ensures that remote mining suffers no performance hit, but after the warmup period (1-2 minutes for the DAG generation), it should become a lot faster. This PR implements this strategy with the following results:

* Initial run with no pre-generated DAG: 800 milliseconds
* Subsequent runs while generating DAG: 6-8 milliseconds
* First run with DAG freshly generated: 550 microseconds
* Subsequent runs while generating future DAG: 90-100 microseconds
* Subsequent runs after generator gets idle: 50-100 microseconds
You can view, comment on, or merge this pull request online at:

https://github.com/ethereum/go-ethereum/pull/17405

— Commit Summary —

* consensus/ethash: use DAGs for remote mining, generate async

— File Changes —

M consensus/ethash/consensus.go (50)
M consensus/ethash/ethash.go (46)
M consensus/ethash/sealer.go (11)

— Patch Links —

https://github.com/ethereum/go-ethereum/pull/17405.patch
https://github.com/ethereum/go-ethereum/pull/17405.diff

Добавить комментарий