Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

Commit

Permalink
Resize sync buffers
Browse files Browse the repository at this point in the history
- The DB buffer should be smaller than the body request buffer,
otherwise we'll never know if we have hit our maximum I/O throughput
  • Loading branch information
carver committed Mar 8, 2019
1 parent 2b8de3c commit f21047c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 3 additions & 2 deletions trinity/sync/full/chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
from trinity.sync.common.peers import WaitingPeers
from trinity.sync.full.constants import (
HEADER_QUEUE_SIZE_TARGET,
BLOCK_QUEUE_SIZE_TARGET,
)
from trinity._utils.datastructures import (
MissingDependency,
Expand All @@ -82,7 +83,7 @@
]

# How big should the pending request queue get, as a multiple of the largest request size
REQUEST_BUFFER_MULTIPLIER = 8
REQUEST_BUFFER_MULTIPLIER = 16


class BaseBodyChainSyncer(BaseService, PeerSubscriber):
Expand Down Expand Up @@ -583,7 +584,7 @@ async def _persist_ready_blocks(self) -> None:
while self.is_operational:
# This tracker waits for all prerequisites to be complete, and returns headers in
# order, so that each header's parent is already persisted.
get_completed_coro = self._block_persist_tracker.ready_tasks(HEADER_QUEUE_SIZE_TARGET)
get_completed_coro = self._block_persist_tracker.ready_tasks(BLOCK_QUEUE_SIZE_TARGET)
completed_headers = await self.wait(get_completed_coro)

if self._block_persist_tracker.has_ready_tasks():
Expand Down
9 changes: 5 additions & 4 deletions trinity/sync/full/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
# BUFFER_SECONDS = 30
# (this should allow plenty of time for peers to fill in the buffer during db writes)
#
# MARGIN = 10
# (better to have a buffer that's too big than to artificially constrain performance)
#
HEADER_QUEUE_SIZE_TARGET = 60000
HEADER_QUEUE_SIZE_TARGET = 6000

# How many blocks to persist at a time
# Only need a few seconds of buffer on the DB write side.
BLOCK_QUEUE_SIZE_TARGET = 1000

0 comments on commit f21047c

Please sign in to comment.