mirror of
https://github.com/netbirdio/netbird.git
synced 2026-08-30 19:41:30 +02:00
log pop
This commit is contained in:
@@ -266,27 +266,29 @@ func (s *GRPCServer) handleUpdates(ctx context.Context, accountID string, peerKe
|
||||
// Start goroutine to Pop from buffer
|
||||
go func() {
|
||||
for {
|
||||
start := time.Now()
|
||||
update, overwrites, timeSinceLastPop, ok := updates.NetworkMap.Pop(ctx)
|
||||
log.WithContext(ctx).Debugf("popped an update for peer %s from the network map buffer in %v (overwrites: %d)", peerKey.String(), time.Since(start), overwrites)
|
||||
if !ok {
|
||||
close(networkMapCh)
|
||||
return
|
||||
}
|
||||
start := time.Now()
|
||||
// start := time.Now()
|
||||
select {
|
||||
case networkMapCh <- networkMapUpdate{
|
||||
msg: update,
|
||||
overwrites: overwrites,
|
||||
timeSinceLastPop: timeSinceLastPop,
|
||||
}:
|
||||
log.WithContext(ctx).Debugf("forwarded an update for peer %s from the network map buffer in %v (overwrites: %d)", peerKey.String(), time.Since(start), overwrites)
|
||||
// log.WithContext(ctx).Debugf("forwarded an update for peer %s from the network map buffer in %v (overwrites: %d)", peerKey.String(), time.Since(start), overwrites)
|
||||
|
||||
// Adaptive debounce: increase delay based on overwrite rate
|
||||
// If many overwrites happened, wait longer to let things settle
|
||||
debounce := s.calculateDebounce(overwrites, timeSinceLastPop)
|
||||
if debounce > 0 {
|
||||
start = time.Now()
|
||||
// start = time.Now()
|
||||
time.Sleep(debounce)
|
||||
log.WithContext(ctx).Debugf("debounced for %v for peer %s (overwrites: %d)", time.Since(start), peerKey.String(), overwrites)
|
||||
// log.WithContext(ctx).Debugf("debounced for %v for peer %s (overwrites: %d)", time.Since(start), peerKey.String(), overwrites)
|
||||
}
|
||||
case <-ctx.Done():
|
||||
return
|
||||
@@ -307,7 +309,7 @@ func (s *GRPCServer) handleUpdates(ctx context.Context, accountID string, peerKe
|
||||
s.cancelPeerRoutines(ctx, accountID, peer)
|
||||
return nil
|
||||
}
|
||||
log.WithContext(ctx).Debugf("received an update for peer %s", peerKey.String())
|
||||
// log.WithContext(ctx).Debugf("received an update for peer %s", peerKey.String())
|
||||
|
||||
if err := s.sendUpdate(ctx, accountID, peerKey, peer, update, srv); err != nil {
|
||||
log.WithContext(ctx).Debugf("error while sending an update to peer %s: %v", peerKey.String(), err)
|
||||
@@ -320,7 +322,7 @@ func (s *GRPCServer) handleUpdates(ctx context.Context, accountID string, peerKe
|
||||
s.cancelPeerRoutines(ctx, accountID, peer)
|
||||
return nil
|
||||
}
|
||||
log.WithContext(ctx).Debugf("sending latest update to peer %s (overwrites: %d)", peerKey.String(), updateData.overwrites)
|
||||
// log.WithContext(ctx).Debugf("sending latest update to peer %s (overwrites: %d)", peerKey.String(), updateData.overwrites)
|
||||
if err := s.sendUpdate(ctx, accountID, peerKey, peer, updateData.msg, srv); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -73,13 +73,13 @@ func (p *PeersUpdateManager) SendImportantUpdate(ctx context.Context, peerID str
|
||||
found = true
|
||||
select {
|
||||
case channel.Important <- update:
|
||||
log.WithContext(ctx).Debugf("update was sent to important channel for peer %s", peerID)
|
||||
// log.WithContext(ctx).Debugf("update was sent to important channel for peer %s", peerID)
|
||||
default:
|
||||
dropped = true
|
||||
log.WithContext(ctx).Warnf("important channel for peer %s is %d full or closed", peerID, len(channel.Important))
|
||||
// log.WithContext(ctx).Warnf("important channel for peer %s is %d full or closed", peerID, len(channel.Important))
|
||||
}
|
||||
} else {
|
||||
log.WithContext(ctx).Debugf("peer %s has no important channel", peerID)
|
||||
// log.WithContext(ctx).Debugf("peer %s has no important channel", peerID)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,9 +100,9 @@ func (p *PeersUpdateManager) SendNetworkMapUpdate(ctx context.Context, peerID st
|
||||
if channel, ok := p.peerChannels[peerID]; ok {
|
||||
found = true
|
||||
channel.NetworkMap.Push(update)
|
||||
log.WithContext(ctx).Debugf("update was sent to network map buffer for peer %s", peerID)
|
||||
// log.WithContext(ctx).Debugf("update was sent to network map buffer for peer %s", peerID)
|
||||
} else {
|
||||
log.WithContext(ctx).Debugf("peer %s has no network map buffer", peerID)
|
||||
// log.WithContext(ctx).Debugf("peer %s has no network map buffer", peerID)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user