mirror of
https://github.com/netbirdio/netbird.git
synced 2025-06-21 18:22:37 +02:00
added dbg logs
This commit is contained in:
parent
ce8e651eb9
commit
fd25265967
@ -168,9 +168,11 @@ func (s *GRPCServer) Sync(req *proto.EncryptedMessage, srv proto.ManagementServi
|
||||
defer func() {
|
||||
if s.appMetrics != nil {
|
||||
s.appMetrics.GRPCMetrics().CountSyncRequestDuration(time.Since(reqStart))
|
||||
log.WithContext(ctx).Infof("Sync request from peer %s took %v", peerKey.String(), time.Since(reqStart))
|
||||
}
|
||||
}()
|
||||
|
||||
syncbody := time.Now()
|
||||
// nolint:staticcheck
|
||||
ctx = context.WithValue(ctx, nbContext.PeerIDKey, peerKey.String())
|
||||
|
||||
@ -224,6 +226,8 @@ func (s *GRPCServer) Sync(req *proto.EncryptedMessage, srv proto.ManagementServi
|
||||
|
||||
log.WithContext(ctx).Debugf("Sync: took %v", time.Since(reqStart))
|
||||
|
||||
log.WithContext(ctx).Info("Sync body after the filter for peer %s took %v", peerKey.String(), time.Since(syncbody))
|
||||
|
||||
return s.handleUpdates(ctx, accountID, peerKey, peer, updates, srv)
|
||||
}
|
||||
|
||||
@ -483,10 +487,13 @@ func (s *GRPCServer) Login(ctx context.Context, req *proto.EncryptedMessage) (*p
|
||||
if s.appMetrics != nil {
|
||||
s.appMetrics.GRPCMetrics().CountLoginRequestDuration(time.Since(reqStart))
|
||||
}
|
||||
log.WithContext(ctx).Infof("Login request from peer %s took %v", peerKey.String(), time.Since(reqStart))
|
||||
}()
|
||||
if s.appMetrics != nil {
|
||||
s.appMetrics.GRPCMetrics().CountLoginRequest()
|
||||
}
|
||||
|
||||
bodytime := time.Now()
|
||||
//nolint
|
||||
ctx = context.WithValue(ctx, nbContext.PeerIDKey, peerKey.String())
|
||||
accountID, err := s.accountManager.GetAccountIDForPeerKey(ctx, peerKey.String())
|
||||
@ -544,6 +551,7 @@ func (s *GRPCServer) Login(ctx context.Context, req *proto.EncryptedMessage) (*p
|
||||
log.WithContext(ctx).Warnf("failed encrypting peer %s message", peer.ID)
|
||||
return nil, status.Errorf(codes.Internal, "failed logging in peer")
|
||||
}
|
||||
log.WithContext(ctx).Info("Login body after the filter for peer %s took %v", peerKey.String(), time.Since(bodytime))
|
||||
|
||||
return &proto.EncryptedMessage{
|
||||
WgPubKey: s.wgKey.PublicKey().String(),
|
||||
|
@ -66,6 +66,7 @@ func newLoginFilterWithCfg(cfg *config) *loginFilter {
|
||||
func (l *loginFilter) allowLogin(wgPubKey string, metaHash uint64) bool {
|
||||
now := time.Now()
|
||||
l.mu.RLock()
|
||||
// defer l.mu.RUnlock()
|
||||
defer func() {
|
||||
l.mu.RUnlock()
|
||||
log.Infof("allowLogin duration for %s: %v", wgPubKey, time.Since(now))
|
||||
@ -88,6 +89,7 @@ func (l *loginFilter) allowLogin(wgPubKey string, metaHash uint64) bool {
|
||||
func (l *loginFilter) addLogin(wgPubKey string, metaHash uint64) {
|
||||
now := time.Now()
|
||||
l.mu.Lock()
|
||||
// defer l.mu.Unlock()
|
||||
defer func() {
|
||||
l.mu.Unlock()
|
||||
log.Infof("addLogin duration for %s: %v", wgPubKey, time.Since(now))
|
||||
|
@ -3,6 +3,7 @@ package server
|
||||
import (
|
||||
"hash/fnv"
|
||||
"math"
|
||||
"math/rand"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
@ -249,3 +250,26 @@ func getMacAddress(nas []nbpeer.NetworkAddress) string {
|
||||
}
|
||||
return strings.Join(macs, "/")
|
||||
}
|
||||
|
||||
func BenchmarkLoginFilter_ParallelLoad(b *testing.B) {
|
||||
filter := newLoginFilterWithCfg(testAdvancedCfg())
|
||||
numKeys := 100000
|
||||
pubKeys := make([]string, numKeys)
|
||||
for i := range numKeys {
|
||||
pubKeys[i] = "PUB_KEY_" + strconv.Itoa(i)
|
||||
}
|
||||
|
||||
b.ResetTimer()
|
||||
b.RunParallel(func(pb *testing.PB) {
|
||||
r := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
|
||||
for pb.Next() {
|
||||
key := pubKeys[r.Intn(numKeys)]
|
||||
meta := r.Uint64()
|
||||
|
||||
if filter.allowLogin(key, meta) {
|
||||
filter.addLogin(key, meta)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user