This is an archive of the discontinued LLVM Phabricator instance.

[Profile] Improve profile dumping with merging
ClosedPublic

Authored by davidxl on Jun 27 2017, 1:42 PM.

Details

Summary

When profile merging is on, the name section in the profile data file won't change after merging. This patch adds support to skip over name section when possible to reduce disk IO.

Do a Clang self build with instrumented clang (IR based), the build time improves a little ~1%. With IR PGO, the name section is relatively small. The total profile size is ~15MB while the compressed name strings is only 2.4MB.

Diff Detail

Repository
rL LLVM

Event Timeline

davidxl created this revision.Jun 27 2017, 1:42 PM
vsk edited edge metadata.Jun 27 2017, 2:59 PM

This sounds like a great idea.

lib/profile/InstrProfilingFile.c
228 ↗(On Diff #104257)

Can you remove the extra fseek in a separate commit?

lib/profile/InstrProfilingWriter.c
281 ↗(On Diff #104257)

If we aren't writing the name data, can't we also avoid writing __llvm_profile_data, and the padding?

davidxl marked an inline comment as done.Jun 27 2017, 3:51 PM
davidxl added inline comments.
lib/profile/InstrProfilingWriter.c
281 ↗(On Diff #104257)

The profile reader uses the counter begin recorded in the header and the counter ptr recorded in data to compute counter offset. Assuming the relative offset remain unchanged, I think it is possible to skip them as well. Since the major cost comes from name section, I'd like to limit the change to name skipping only.

vsk accepted this revision.Jun 27 2017, 5:34 PM

Thanks, lgtm.

lib/profile/InstrProfilingWriter.c
281 ↗(On Diff #104257)

Ok, I see this in RawInstrProfReader::getCounter.

This revision is now accepted and ready to land.Jun 27 2017, 5:34 PM
This revision was automatically updated to reflect the committed changes.