Open zamazan4ik opened 8 months ago
I'm using mongodb v4.4.0, adding -profile-generate to cflags, cxxflags and linkflags, after mongo is started, a empty profile raw data file is generate, but it is always empty, even I use "use admin; db.shutdownServer()" to stop mongodb, the profile raw data file is still empty, could you give some hits why this happens?
I cannot surely say what is the reason for such behavior with mongod. Instead, I can suggest you patch mongod a bit and implement manual dumping of PGO profiles to a file like it's done in other databases like YugabyteDB: https://github.com/yugabyte/yugabyte-db/blob/master/src/yb/common/llvm_profile_dumper.cc . I am almost sure that it should resolve your problems with empty profiles.
Regarding the root cause of the problem. Probably, mongod has some specific code around the application exit, and that's why an automatic save approach at the exit doesn't work well in this case.
According to the https://github.com/llvm/llvm-project/issues/45668 now IR PGO (
-fprofile-generate
/-fprofile-use
flags in Clang) is the recommended way to do PGO in applications. All current investments in the PGO area in LLVM now are done in the IR PGO.We need to perform some kind of migration for open-source projects from old, FrontEnd PGO (
-fprofile-instr-generate
/-fprofile-instr-use
flags in Clang) to IR PGO.The current list is the following:
We need to check more projects and add them here.