Page MenuHomePhabricator

[XRay] Use preallocated memory for XRay profiling
ClosedPublic

Authored by dberris on Dec 3 2018, 9:12 PM.

Details

Summary

This change builds upon D54989, which removes memory allocation from the
critical path of the profiling implementation. This also changes the API
for the profile collection service, to take ownership of the memory and
associated data structures per-thread.

The consolidation of the memory allocation allows us to do two things:

  • Limits the amount of memory used by the profiling implementation, associating preallocated buffers instead of allocating memory on-demand.
  • Consolidate the memory initialisation and cleanup by relying on the buffer queue's reference counting implementation.

We find a number of places which also display some problematic
behaviour, including:

  • Off-by-factor bug in the allocator implementation.
  • Unrolling semantics in cases of "memory exhausted" situations, when managing the state of the function call trie.

We also add a few test cases which verify our understanding of the
behaviour of the system, with important edge-cases (especially for
memory-exhausted cases) in the segmented array and profile collector
unit tests.

Depends on D54989.

Diff Detail

Repository
rL LLVM

Event Timeline

dberris created this revision.Dec 3 2018, 9:12 PM
mboerger added inline comments.Dec 4 2018, 10:45 PM
compiler-rt/lib/xray/xray_profiling.cc
359 ↗(On Diff #176544)

maybe not :-)

dberris updated this revision to Diff 176766.Dec 4 2018, 10:57 PM
dberris marked an inline comment as done.

Addressing comment by @mboerger.

dberris updated this revision to Diff 177124.Dec 6 2018, 10:01 PM

Rebase again. This is now ready for another look.

This revision is now accepted and ready to land.Dec 6 2018, 10:23 PM
This revision was automatically updated to reflect the committed changes.