Skip to content

perf(agent): release bpfAllocationMutex before expensive binaryParser.Parse #94

@KorsarOfficial

Description

@KorsarOfficial

Problem

Registry.populateDSO in dso/map.go holds an exclusive sync.Mutex for the entire function duration, including the expensive binaryParser.Parse(ctx, f) ELF parsing operation:

dso.bpfAllocationMutex.Lock()
defer dso.bpfAllocationMutex.Unlock()

// ... fast allocation check ...

analysis, err := d.binaryParser.Parse(ctx, f)  // slow — held under lock

This serialises all concurrent DSO loads on a single binary parse, which can be significant at agent startup when many processes are discovered simultaneously.

Proposed fix

  1. Change sync.Mutexsync.RWMutex
  2. Fast path (check + MoveFromCache/Release) stays under exclusive lock — remains fast
  3. binaryParser.Parse runs without any lock
  4. Write lock re-acquired to store result, with double-check guard against concurrent population

Files affected

  • perforator/agent/collector/pkg/dso/map.go

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions