This is an archive of the discontinued LLVM Phabricator instance.

[profile] Add support for static counter allocation for value profiling (part-1)
ClosedPublic

Authored by davidxl on May 19 2016, 9:14 PM.

Details

Summary

Current value profiler implementation relies on libc runtime for lazy allocation of profile counters. While this is flexible, it limits the usability greatly for apps running in restricted runtime environment.

With this change, VP will now have counters allocated statically by default. Dynamic allocation is still supported which is controlled by compile time option.

The implementation chooses allocate only one node per-site. Tested with instrumented clang (compiing a large C++ source) -- the total number of values collected at runtime is a still quite smaller than statically allocated # of counters .

Diff Detail

Repository
rL LLVM

Event Timeline

davidxl updated this revision to Diff 57886.May 19 2016, 9:14 PM
davidxl retitled this revision from to [profile] Add support for static counter allocation for value profiling (part-1).
davidxl updated this object.
davidxl added reviewers: vsk, xur.
davidxl added a subscriber: llvm-commits.
silvas accepted this revision.May 19 2016, 9:31 PM
silvas added a reviewer: silvas.
silvas added a subscriber: silvas.

This is very exciting. This will hopefully make VP feasible on PS4.

A couple small comments but this LGTM.

lib/Transforms/Instrumentation/InstrProfiling.cpp
40 ↗(On Diff #57886)

Typo avverage.

42 ↗(On Diff #57886)

This is a very interesting statistic.

443 ↗(On Diff #57886)

Can you expand on the explanation here?

This revision is now accepted and ready to land.May 19 2016, 9:31 PM
davidxl added inline comments.May 19 2016, 9:43 PM
lib/Transforms/Instrumentation/InstrProfiling.cpp
443 ↗(On Diff #57886)

The small ratio we choose for #counters over #of sites is based on the observation of large apps with large number of value sites, in which majority of them either have no profile or small number of values. When the number of sites is small, we won't have this average effect. Ideally we should do this computation at link time -- but we will need to do this on a per-module basis. The value 10 can still be tuned -- for instance to make small programs like SPEC happy.

davidxl updated this revision to Diff 57890.May 19 2016, 9:45 PM
davidxl edited edge metadata.

Fixed typo.

silvas added inline comments.May 19 2016, 9:53 PM
lib/Transforms/Instrumentation/InstrProfiling.cpp
443 ↗(On Diff #57890)

Thanks, that makes sense. Can you mention this in the comment?

davidxl updated this revision to Diff 57949.May 20 2016, 10:08 AM

Adjusted and added comments for cases with very few value sites.

davidxl updated this revision to Diff 57965.May 20 2016, 12:07 PM

Fix a bug that triggers debug assert (pointer type mismatch).

This revision was automatically updated to reflect the committed changes.