[PATCH] D19298: [profile] Support for memory-mapping counters to a raw profile

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 19 16:16:49 PDT 2016


vsk created this revision.
vsk added a reviewer: llvm-commits.
vsk added a subscriber: davidxl.

**Summary**

Using memory-mapped profile counters makes it possible to take snapshots of a running process's profiling information without changing the program. This is useful if the process exits abnormally, or if profiling data needs to be collected periodically.

Add the compiler-rt support required to create instrumented programs which memory-map their counters directly onto a raw profile.

**More details**

The memory-mapped counters feature works by writing out an empty raw profile at program start time, and then setting up an mmap. If this fails, we clean up and fall back to the normal atexit() profile writer.

One complication arises with profile truncation. The atexit() writer is able to truncate profiles every time `__llvm_profile_initialize_file()` is called. The mmap() writer can't do this because it needs to preserve the profiling data created by shared objects. The solution I picked is to use a lock file to synchronize truncation efforts.

http://reviews.llvm.org/D19298

Files:
  lib/profile/InstrProfData.inc
  lib/profile/InstrProfiling.h
  lib/profile/InstrProfilingBuffer.c
  lib/profile/InstrProfilingFile.c
  lib/profile/InstrProfilingInternal.h
  lib/profile/InstrProfilingRuntime.cc
  lib/profile/InstrProfilingUtil.c
  lib/profile/InstrProfilingUtil.h
  lib/profile/InstrProfilingWriter.c
  test/lit.common.cfg
  test/profile/CMakeLists.txt
  test/profile/Linux/coverage_ctors.cpp
  test/profile/Linux/coverage_dtor.cpp
  test/profile/Linux/coverage_shared.test
  test/profile/Linux/coverage_test.cpp
  test/profile/Linux/instrprof-basic.c
  test/profile/Linux/instrprof-dlopen.test
  test/profile/Linux/instrprof-dynamic-one-shared.test
  test/profile/Linux/instrprof-dynamic-two-shared.test
  test/profile/gcc-flag-compatibility.test
  test/profile/instrprof-basic.c
  test/profile/instrprof-bufferio.c
  test/profile/instrprof-dlopen.test
  test/profile/instrprof-dynamic-one-shared.test
  test/profile/instrprof-dynamic-two-shared.test
  test/profile/instrprof-error.c
  test/profile/instrprof-hostname.c
  test/profile/instrprof-merge-match.test
  test/profile/instrprof-merge.c
  test/profile/instrprof-mmap-darwin.c
  test/profile/instrprof-reset-counters.c
  test/profile/instrprof-shared.test
  test/profile/instrprof-visibility.cpp
  test/profile/instrprof-without-libc.c
  test/profile/lit.cfg
  test/profile/lit.site.cfg.in

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19298.54291.patch
Type: text/x-patch
Size: 43158 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160419/8f4a1c2c/attachment.bin>


More information about the llvm-commits mailing list