From 0dac5ddfb51c903de1f8e6c4cbafc9fa8be643f9 Mon Sep 17 00:00:00 2001 From: Nayef Ghattas Date: Thu, 21 Nov 2024 12:32:26 +0100 Subject: [PATCH] reporter: don't expire actively used executables (#247) --- go.mod | 5 ++--- go.sum | 8 ++------ main.go | 2 +- reporter/otlp_reporter.go | 10 ++++++++-- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/go.mod b/go.mod index d94fc264..145446b0 100644 --- a/go.mod +++ b/go.mod @@ -3,12 +3,12 @@ module go.opentelemetry.io/ebpf-profiler go 1.22.2 require ( + github.com/aws/aws-sdk-go-v2 v1.30.5 github.com/aws/aws-sdk-go-v2/config v1.27.35 - github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.21 github.com/aws/aws-sdk-go-v2/service/s3 v1.62.0 github.com/cespare/xxhash/v2 v2.3.0 github.com/cilium/ebpf v0.16.0 - github.com/elastic/go-freelru v0.15.0 + github.com/elastic/go-freelru v0.16.0 github.com/elastic/go-perf v0.0.0-20241016160959-1342461adb4a github.com/google/uuid v1.6.0 github.com/jsimonetti/rtnetlink v1.4.2 @@ -29,7 +29,6 @@ require ( ) require ( - github.com/aws/aws-sdk-go-v2 v1.30.5 // indirect github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.4 // indirect github.com/aws/aws-sdk-go-v2/credentials v1.17.33 // indirect github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.13 // indirect diff --git a/go.sum b/go.sum index 10c61a9e..7fe300bb 100644 --- a/go.sum +++ b/go.sum @@ -8,8 +8,6 @@ github.com/aws/aws-sdk-go-v2/credentials v1.17.33 h1:lBHAQQznENv0gLHAZ73ONiTSkCt github.com/aws/aws-sdk-go-v2/credentials v1.17.33/go.mod h1:MBuqCUOT3ChfLuxNDGyra67eskx7ge9e3YKYBce7wpI= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.13 h1:pfQ2sqNpMVK6xz2RbqLEL0GH87JOwSxPV2rzm8Zsb74= github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.13/go.mod h1:NG7RXPUlqfsCLLFfi0+IpKN4sCB9D9fw/qTaSB+xRoU= -github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.21 h1:sV0doPPsRT7gMP0BnDPwSsysVTV/nKpB/nFmMnz8goE= -github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.21/go.mod h1:ictvfJWqE2gkUFDRJVp5VU/TrytuzK88DYcpan7UYuA= github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.17 h1:pI7Bzt0BJtYA0N/JEC6B8fJ4RBrEMi1LBrkMdFYNSnQ= github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.17/go.mod h1:Dh5zzJYMtxfIjYW+/evjQ8uj2OyR/ve2KROHGHlSFqE= github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.17 h1:Mqr/V5gvrhA2gvgnF42Zh5iMiQNcOYthFYwCyrnuWlc= @@ -43,10 +41,8 @@ github.com/cilium/ebpf v0.16.0/go.mod h1:L7u2Blt2jMM/vLAVgjxluxtBKlz3/GWjB0dMOEn github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/elastic/go-freelru v0.13.0 h1:TKKY6yCfNNNky7Pj9xZAOEpBcdNgZJfihEftOb55omg= -github.com/elastic/go-freelru v0.13.0/go.mod h1:bSdWT4M0lW79K8QbX6XY2heQYSCqD7THoYf82pT/H3I= -github.com/elastic/go-freelru v0.15.0 h1:Jo1aY8JAvpyxbTDJEudrsBfjFDaALpfVv8mxuh9sfvI= -github.com/elastic/go-freelru v0.15.0/go.mod h1:bSdWT4M0lW79K8QbX6XY2heQYSCqD7THoYf82pT/H3I= +github.com/elastic/go-freelru v0.16.0 h1:gG2HJ1WXN2tNl5/p40JS/l59HjvjRhjyAa+oFTRArYs= +github.com/elastic/go-freelru v0.16.0/go.mod h1:bSdWT4M0lW79K8QbX6XY2heQYSCqD7THoYf82pT/H3I= github.com/elastic/go-perf v0.0.0-20241016160959-1342461adb4a h1:ymmtaN4bVCmKKeu4XEf6JEWNZKRXPMng1zjpKd+8rCU= github.com/elastic/go-perf v0.0.0-20241016160959-1342461adb4a/go.mod h1:Nt+pnRYvf0POC+7pXsrv8ubsEOSsaipJP0zlz1Ms1RM= github.com/go-quicktest/qt v1.101.0 h1:O1K29Txy5P2OK0dGo59b7b0LR6wKfIhttaAhHUyn7eI= diff --git a/main.go b/main.go index 7a5e0330..106413b8 100644 --- a/main.go +++ b/main.go @@ -124,7 +124,7 @@ func mainWithExitCode() exitCode { GRPCStartupBackoffTime: intervals.GRPCStartupBackoffTime(), GRPCConnectionTimeout: intervals.GRPCConnectionTimeout(), ReportInterval: intervals.ReportInterval(), - ExecutablesCacheElements: 4096, + ExecutablesCacheElements: 16384, // Next step: Calculate FramesCacheElements from numCores and samplingRate. FramesCacheElements: 65536, CGroupCacheElements: 1024, diff --git a/reporter/otlp_reporter.go b/reporter/otlp_reporter.go index de21787c..c2fbdf29 100644 --- a/reporter/otlp_reporter.go +++ b/reporter/otlp_reporter.go @@ -29,6 +29,10 @@ import ( "go.opentelemetry.io/ebpf-profiler/libpf/xsync" ) +const ( + executableCacheLifetime = 1 * time.Hour +) + // Assert that we implement the full Reporter interface. var _ Reporter = (*OTLPReporter)(nil) @@ -147,7 +151,7 @@ func NewOTLP(cfg *Config) (*OTLPReporter, error) { if err != nil { return nil, err } - executables.SetLifetime(1 * time.Hour) // Allow GC to clean stale items. + executables.SetLifetime(executableCacheLifetime) // Allow GC to clean stale items. frames, err := lru.NewSynced[libpf.FileID, *xsync.RWMutex[map[libpf.AddressOrLineno]sourceInfo]]( @@ -574,7 +578,9 @@ func (r *OTLPReporter) getProfile() (profile *profiles.Profile, startTS, endTS u fileIDtoMapping[traceInfo.files[i]] = idx locationMappingIndex = idx - execInfo, exists := r.executables.Get(traceInfo.files[i]) + // Ensure that actively used executables do not expire. + execInfo, exists := r.executables.GetAndRefresh(traceInfo.files[i], + executableCacheLifetime) // Next step: Select a proper default value, // if the name of the executable is not known yet.