Unable to distinguish between AggregatedLBREntry types FT and FT_EXTERNAL_ORIGIN without binary information

I am currently aiming to convert sample information saved in a database into a pre-aggregated format file.
According to my understanding, bolt does not provide a method to output pre-aggregated LBR samples. Moreover, from inspecting the source code of bolt, I’ve learned that the two types of AggregatedLBREntry, FT and FT_EXTERNAL_ORIGIN, are distinguished based on whether the FallThrough’s First.from and First.to occur within a BinaryFunction. Therefore, I believe that it is not possible to output a pre-aggregated file without the binary information, which seems contradictory to a statement in parsePreAggregated that says “The pre-aggregated file contains aggregated LBR data, but without binary knowledge.”

My question is, if I want to use a pre-aggregated file, do I need to additionally save the First.from to differentiate between FT and FT_EXTERNAL_ORIGIN during the perf2bolt process? This method seems feasible, yet somewhat odd, and it requires me to save additional data.

As I replied on another question, this is known omission, and fix is in progress. To give you some more context how fallthrough with external origin came about, consider the profile with a branch corresponding to a return from function in shared library back into the main binary. The fallthrough range that starts with this return needs to be distinguished from internal branch, in order to correctly set call-to-continuation fallthrough (in former case we need to increment it, in latter we don’t). This special fallthrough type was introduced to distinguish these two cases. However it assumed function-external origin, which also includes returns from another function in the same binary. Pre-aggregation tool would need to know function boundaries in order to correctly set this, which is a redundant information because BOLT does this as well.

So the correct approach would be to combine branches and fallthrough ranges into triplets of (From, To, Fallthrough End) which would provide all the necessary information for fallthrough origin determination. This also reduces the size of pre-aggregated profile and slightly improves performance.

Thank you, this is a good idea, I will try it.