[CSSPGO] Sort function offset table to speed up profile loading.
authorHongtao Yu <hoy@fb.com>
Tue, 31 Aug 2021 23:30:49 +0000 (16:30 -0700)
committerHongtao Yu <hoy@fb.com>
Wed, 1 Sep 2021 19:17:48 +0000 (12:17 -0700)
commitf4711e0d009b7e62fc1fa3c070878ad366710487
treedf3bcd0df74c809d3edd5d6ce85ec51bbad37dcd
parent02f74eadbe2f56db4807dbc785a99e941a98300a
[CSSPGO] Sort function offset table to speed up profile loading.

With the context split work, the context-based (an array of strings) sorting performed at profile load time is way more expansive than single-string-based sorting. This is likely due to auxiliary operations done on each array element, such as indirect references, std::min operations, also likely cache misses. In this change I'm presorting profiles during profile generation time to avoid sorting at compile time.

Compared to the previous context-split work, this effectively cuts down compile time by 20% for one of our large services and brings us closer to non-CS build, with still a small gap in build time.

Reviewed By: wenlei, wmi

Differential Revision: https://reviews.llvm.org/D109036
llvm/include/llvm/ProfileData/SampleProf.h
llvm/include/llvm/ProfileData/SampleProfReader.h
llvm/lib/ProfileData/SampleProfReader.cpp
llvm/lib/ProfileData/SampleProfWriter.cpp
llvm/test/Transforms/SampleProfile/csspgo-import-list.ll