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

avoid performing garbage collect on each topology update #118

Merged
merged 4 commits into from
Oct 10, 2019

Conversation

murali-reddy
Copy link
Contributor

Fixes: #115

@bboreham
Copy link
Contributor

I think I would be happier if we did a garabgeCollect somewhere.
Maybe do it on the gossipTimer in localPeer ?

@murali-reddy
Copy link
Contributor Author

Updated PR to perform garbage collect corresponding to topology updates. Also timer is used trigger garbage collect at scheduled interval which will help coalesce topology updates.

peers.go Outdated Show resolved Hide resolved
peers.go Show resolved Hide resolved
@murali-reddy
Copy link
Contributor Author

addressed review comments. PTAL

peers.go Outdated Show resolved Hide resolved
gossip_test.go Outdated
@@ -66,6 +67,8 @@ func sendPendingGossip(routers ...*Router) {
sentSomething = router.sendPendingGossip() || sentSomething
}
}
// Allow topology to propagate
time.Sleep(1 * time.Second)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't like this - sendPendingGossip() is carefully written to wait long enough already.

You could add a new function in peers_test.go like:

func forcePendingGC(routers ...*Router) {
	for _, router := range routers {
		router.Peers.Lock()
		if router.Peers.pendingGC {
			var pending peersPendingNotifications
			router.Peers.garbageCollect(&pending)
			router.Peers.unlockAndNotify(&pending)
		} else {
			router.Peers.Unlock()
		}
	}
}

then call it as necessary?

@bboreham
Copy link
Contributor

I note we can't run go test -race on this package any more, because TestDeferredShortIDReassignment() needs to create 4096 peers, and each peer now creates two goroutines, and the Go / LLVM ThreadSanitizer has a limit of 8128 goroutines.

@bboreham bboreham merged commit ea482fe into master Oct 10, 2019
@bboreham bboreham deleted the gc-topology-update branch October 10, 2019 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

high rate of Peers.garbageCollect() calls resulting from topology gossip
2 participants