This repository has been archived by the owner. It is now read-only.

only update subscribers if there are any #2809

Merged
merged 2 commits into from Mar 2, 2018

Conversation

Projects
None yet
3 participants
@tbenz9
Collaborator

tbenz9 commented Mar 2, 2018

When syncing the consensus.db from genesis as much as 25% of the time it takes to sync is spent on cs.updateSubscribers(). There is no need update subscribers if you don't have any.

If you start siad with only a subset of the modules you may not have any subscribers. For example siad -M cg -d /root/Sia results in 0 subscribers.

cs.updateSubscribers(changes[i])

@tbenz9

This comment has been minimized.

Collaborator

tbenz9 commented Mar 2, 2018

I'll explain my use case a bit more, I like to always sync the blockchain from the network, and avoid bootstrapping when I can. I've been a little frustrated with how slow it is to sync from genesis, I discovered that if I start siad with only the consensus and gateway modules loaded I could sync the consensus much faster than usual. My plan is to sync quickly, then restart siad with the rest of the modules. This could be a relatively easy route for non-bootstrapping performance improvements.

for i := 0; i < len(changes); i++ {
cs.updateSubscribers(changes[i])
// Check if there are any subscribers
if len(cs.subscribers) > 0 {

This comment has been minimized.

@ChrisSchinnerl

ChrisSchinnerl Mar 2, 2018

Contributor

I feel like I would prefer this check inside of updateSubscribers. Something like the following at the beginning of the function. That way we don't need to add the check every time if we call updateSubscribers in multiple places.

if len(cs.subscribers) == 0 {
    return
}

@lukechampine lukechampine merged commit 978bed1 into NebulousLabs:master Mar 2, 2018

1 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details

@tbenz9 tbenz9 deleted the tbenz9:consensus-optimization branch Mar 5, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.