Skip to content

Commit

Permalink
reporter: split reporter cache sizes definition
Browse files Browse the repository at this point in the history
without impacting the cache sizes, we can refine this later on
based on the runtime profiler outputs internally
  • Loading branch information
Gandem committed Nov 19, 2024
1 parent 0420b4e commit 5970b69
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
21 changes: 12 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,18 @@ func mainWithExitCode() exitCode {
}

rep, err := reporter.NewDatadog(&reporter.Config{
IntakeURL: intakeURL,
Version: versionInfo.Version,
ReportInterval: intervals.ReportInterval(),
CacheSize: traceHandlerCacheSize,
SamplesPerSecond: int(args.samplesPerSecond),
PprofPrefix: args.pprofPrefix,
Tags: validatedTags,
Timeline: args.timeline,
APIKey: apiKey,
IntakeURL: intakeURL,
Version: versionInfo.Version,
ReportInterval: intervals.ReportInterval(),
ExecutablesCacheElements: traceHandlerCacheSize,
// Next step: Calculate FramesCacheElements from numCores and samplingRate.
FramesCacheElements: traceHandlerCacheSize,
ProcessesCacheElements: traceHandlerCacheSize,
SamplesPerSecond: int(args.samplesPerSecond),
PprofPrefix: args.pprofPrefix,
Tags: validatedTags,
Timeline: args.timeline,
APIKey: apiKey,
SymbolUploaderConfig: reporter.SymbolUploaderConfig{
Enabled: args.uploadSymbols,
UploadDynamicSymbols: args.uploadDynamicSymbols,
Expand Down
8 changes: 6 additions & 2 deletions reporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ type Config struct {
Version string
// IntakeURL defines the URL of profiling intake.
IntakeURL string
// CacheSize defines the size of the reporter caches.
CacheSize uint32
// ExecutablesCacheElements defines item capacity of the executables cache.
ExecutablesCacheElements uint32
// FramesCacheElements defines the item capacity of the frames cache.
FramesCacheElements uint32
// ProcessesCacheElements defines the item capacity of the processes cache.
ProcessesCacheElements uint32
// samplesPerSecond defines the number of samples per second.
SamplesPerSecond int
// ReportInterval defines the interval at which the agent reports data to the collection agent.
Expand Down
6 changes: 3 additions & 3 deletions reporter/datadog_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ type DatadogReporter struct {
}

func NewDatadog(cfg *Config, p containermetadata.Provider) (*DatadogReporter, error) {
executables, err := lru.NewSynced[libpf.FileID, execInfo](cfg.CacheSize, libpf.FileID.Hash32)
executables, err := lru.NewSynced[libpf.FileID, execInfo](cfg.ExecutablesCacheElements, libpf.FileID.Hash32)
if err != nil {
return nil, err
}
Expand All @@ -151,13 +151,13 @@ func NewDatadog(cfg *Config, p containermetadata.Provider) (*DatadogReporter, er
// required for the profile to be correctly displayed in the Datadog UI.

frames, err := lru.NewSynced[libpf.FileID,
*xsync.RWMutex[map[libpf.AddressOrLineno]sourceInfo]](cfg.CacheSize, libpf.FileID.Hash32)
*xsync.RWMutex[map[libpf.AddressOrLineno]sourceInfo]](cfg.FramesCacheElements, libpf.FileID.Hash32)
if err != nil {
return nil, err
}
frames.SetLifetime(1 * time.Hour) // Allow GC to clean stale items.

processes, err := lru.NewSynced[libpf.PID, processMetadata](cfg.CacheSize, libpf.PID.Hash32)
processes, err := lru.NewSynced[libpf.PID, processMetadata](cfg.ProcessesCacheElements, libpf.PID.Hash32)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 5970b69

Please sign in to comment.