Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

capi: buffer blocks in a separate thread #1787

Merged
merged 14 commits into from
Feb 9, 2024

Conversation

JacekGlen
Copy link
Member

In this PR a separate thread is started with a callable object BlockProvider. This constantly adds new blocks to the block_buffer. The underlying class BoundedBuffer is thread-safe and handles two cases:

  • insert item waits if the buffer is full
  • pop item waits if the buffer is empty

By offloading the block reading to a separate thread we gain ~4% of the block execution time.

@canepat canepat added the performance Performance issue or improvement label Jan 31, 2024
silkworm/capi/silkworm.cpp Outdated Show resolved Hide resolved
silkworm/capi/silkworm.cpp Outdated Show resolved Hide resolved
silkworm/capi/silkworm.cpp Outdated Show resolved Hide resolved
silkworm/capi/silkworm.cpp Outdated Show resolved Hide resolved
silkworm/capi/silkworm.cpp Outdated Show resolved Hide resolved
silkworm/infra/common/bounded_buffer.hpp Outdated Show resolved Hide resolved
silkworm/infra/common/bounded_buffer.hpp Outdated Show resolved Hide resolved
silkworm/infra/common/bounded_buffer.hpp Outdated Show resolved Hide resolved
silkworm/infra/common/bounded_buffer.hpp Outdated Show resolved Hide resolved
silkworm/infra/common/bounded_buffer.hpp Outdated Show resolved Hide resolved
@canepat canepat added the c api The C API exposed for Erigon label Feb 9, 2024
@canepat canepat merged commit 782b019 into master Feb 9, 2024
4 checks passed
@canepat canepat deleted the node-block-execution-performance2 branch February 9, 2024 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c api The C API exposed for Erigon performance Performance issue or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants