risechain / pevm

Blazingly fast Parallel EVM
MIT License
214 stars 39 forks source link

Reuse a `rayon` thread pool in `Pevm` between runs #377

Open hai-rise opened 5 days ago

hai-rise commented 5 days ago

See https://github.com/risechain/pevm/issues/309#issuecomment-2401775949.

hai-rise commented 5 days ago

@byhashdong Here it is, sir!

byhashdong commented 8 hours ago
hai-rise commented 1 minute ago

after trying rayon, get same result, the performance is worse than original thread pool implementation

Hopefully one day we understand why!

having a little test, found time gap between all threads completed and scoped completed normally less than 100us.

Ah yes, the scope should end immediately when all threads join. The original idea is more about starting to post-process when Scheduler announces that execution has been done, so even before all threads have completed joining!

confused, while task.is_some() { as the code, thread should exit if there is no new work to do.

While looking for a Scheduler::next_task, we currently loop until execution is done or aborted: https://github.com/risechain/pevm/blob/bed6f220c343d03e6bef0dc7540c531444450d57/src/scheduler.rs#L118-L119

We can add a counter here to return a None to join a thread early when it fails to find a job after X iterations.