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

a few small changes to make the dht more efficient #2841

Merged
merged 2 commits into from
Jun 12, 2016

Conversation

whyrusleeping
Copy link
Member

Was watching biham during a reproviding round. Its eating up some serious CPU time, this should help alleviate a small amount of that.

License: MIT
Signed-off-by: Jeromy why@ipfs.io

License: MIT
Signed-off-by: Jeromy <why@ipfs.io>
License: MIT
Signed-off-by: Jeromy <why@ipfs.io>
@Kubuxu
Copy link
Member

Kubuxu commented Jun 12, 2016

LGTM

@Kubuxu Kubuxu added the RFM label Jun 12, 2016
@whyrusleeping
Copy link
Member Author

should improve #2828

@whyrusleeping whyrusleeping merged commit 0ff2dc9 into master Jun 12, 2016
@whyrusleeping whyrusleeping deleted the feat/efficient-dht branch June 12, 2016 21:05
peerID := ConvertPeerID(p)
cpl := commonPrefixLen(peerID, rt.local)

rt.tabLock.Lock()
defer rt.tabLock.Unlock()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this no longer protects rt.local, which is fine. BUT it would be nice if the RoutingTable struct was more clear about what the mutex protects.

now

// RoutingTable defines the routing table.
type RoutingTable struct {

    // ID of the local peer
    local ID

    // Blanket lock, refine later for better performance
    tabLock sync.RWMutex

    // latency metrics
    metrics pstore.Metrics

    // Maximum acceptable latency for peers in this cluster
    maxLatency time.Duration

    // kBuckets define all the fingers to other nodes.
    Buckets    []*Bucket
    bucketsize int
}

better

// RoutingTable defines the routing table.
type RoutingTable struct {

    local      ID  // ID of the local peer
    bucketsize int

    // the following fields are all protected by tabLock
    tabLock    sync.RWMutex   // Blanket lock, refine later for better performance
    metrics    pstore.Metrics // latency metrics
    maxLatency time.Duration  // Maximum acceptable latency for peers in this cluster
    Buckets    []*Bucket      // kBuckets define all the fingers to other nodes.
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or at least say:

    // Blanket lock, refine later for better performance
    // protects metrics, maxLatency, and Buckets
    tabLock sync.RWMutex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants