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

reduce log spam from empty heartbeat messages #441

Merged
merged 2 commits into from
Jul 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion gossipsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ type GossipSubParams struct {
// HeartbeatInterval controls the time between heartbeats.
HeartbeatInterval time.Duration

// SlowHeartbeatWarning is the duration threshold for heartbeat processing before emitting
// a warning; this would be indicative of an overloaded peer.
SlowHeartbeatWarning float64

// FanoutTTL controls how long we keep track of the fanout state. If it's been
// FanoutTTL since we've published to a topic that we're not subscribed to,
// we'll delete the fanout map for that topic.
Expand Down Expand Up @@ -251,6 +255,7 @@ func DefaultGossipSubParams() GossipSubParams {
MaxIHaveLength: GossipSubMaxIHaveLength,
MaxIHaveMessages: GossipSubMaxIHaveMessages,
IWantFollowupTime: GossipSubIWantFollowupTime,
SlowHeartbeatWarning: 0.1,
}
}

Expand Down Expand Up @@ -1296,7 +1301,15 @@ func (gs *GossipSubRouter) heartbeatTimer() {
}

func (gs *GossipSubRouter) heartbeat() {
defer log.Infow("heartbeat")
start := time.Now()
defer func() {
if gs.params.SlowHeartbeatWarning > 0 {
slowWarning := time.Duration(gs.params.SlowHeartbeatWarning * float64(gs.params.HeartbeatInterval))
if dt := time.Since(start); dt > slowWarning {
log.Warnw("slow heartbeat", "took", dt)
}
}
}()

gs.heartbeatTicks++

Expand Down