Currently, the full build path gets included in the name of static function profile counters. When the training build and the profile guided build are in different directories, we end up just dropping the profile data and get a warning about unprofiled functions. Using only the filename in the counter prevents this problem, but seems good only as a short term solution.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
I think this should be controlled by an internal option -- I think default can be stripping the path as done in this patch: it is unlikely that two static functions have source files with the same name and the same cfg hash.
For posterity, I want to expand a bit on Jake's explanation:
When the training build and the profile guided build are in different directories, we end up just dropping the profile data and get a warning about unprofiled functions.
To expand on Jake's explanation of this issue, the issue we ran into when building one of our games is actually slightly more complicated than he described. The main complication is that the build generates source files into the build directory. Thus, different build directories (as one might use for separate prof-gen and prof-use builds) cause issues.
Concretely:
During the build, SOURCE_DIR/foo/bar/baz.cpp files are processed by a special tool into BUILD_DIR/foo/bar/baz.hashed.cpp before being passed to the compiler (essentially, the tool replaces certain marked strings with an integer hash code of the string).
During a PGO build, the following happens:
- The prof-gen build is done into PGO_TRAIN_BUILD_DIR. Thus, counters for *all* static functions end up with a name like PGO_TRAIN_BUILD_DIR/foo/bar/baz.hashed.cpp:funcname.
- The prof-use build is done into PGO_BUILD_DIR. Thus, the counter name that is expected is PGO_BUILD_DIR/foo/bar/baz.hashed.cpp:funcname. Thus, the counter is not found. This affects *all* static functions.
Pre-inline mitigates the issue significantly (since static functions are likely to be inlined), but we still saw it occur in practice.
Added a flag for controlling the behavior of this. Keeping the name short but informative makes the flag name somewhat weird but just let me know if you have some preference on the naming.
Sean or David, could one of you please commit this for me, I don't have commit access. Thanks!