snarkOS icon indicating copy to clipboard operation
snarkOS copied to clipboard

Skip computing block locators if peer is disconnected

Open howardwu opened this issue 2 years ago • 3 comments

Motivation

This PR improves the efficiency of validators and beacons by checking that the peer is still connected prior to preparing a Ping message.

While the call to send_ping will already check that the peer is still connected (via logic in can_send), it was observed that validators and beacons (due to the number of connections they maintain) frequently prepare block locators that are not used as the peer has already disconnected.

This PR thus significantly reduces the number of calls to Ledger for validators and beacons, thereby improving the efficiency in usage of RocksDB for other operations such as syncing blocks.

howardwu avatar Dec 05 '22 03:12 howardwu

Validator will always get block locators when perform_handshake, however, there's no need to do it when peer is a Prover or a Client,right? https://github.com/AleoHQ/snarkOS/pull/2147

ghostant-1017 avatar Dec 05 '22 03:12 ghostant-1017

Validator will always get block locators when perform_handshake, however, there's no need to do it when peer is a Prover or a Client,right? #2147

I've answered this in PR 2147, thanks

howardwu avatar Dec 05 '22 04:12 howardwu

Validator will always get block locators when perform_handshake, however, there's no need to do it when peer is a Prover or a Client,right? #2147

I've answered this in PR 2147, thanks

Ok, Maybe we can cached the block_locator and update it when new block is coming. https://github.com/AleoHQ/snarkOS/pull/2152

ghostant-1017 avatar Dec 05 '22 05:12 ghostant-1017