Description
The largest unanswered questions about implicit caller location are about the binary size impact of the feature and how to offer users control over it.
There are three ways I see that #[track_caller]
inflates binaries:
- code bloat from panicking branches that were previously fused
- encoding the
Location
structs themselves - encoding the
&'static str
for every filename referenced by aLocation
We need to determine the impact to the ecosystem for each of these before deciding on mitigation strategy.
(1) was the main concern in the RFC but it was predicated on the assumption that #[track_caller]
would affect inlining (an artifact of the implementation proposed). Since it doesn't affect inlining now, the only lost optimization in panicking branches would be for cases where LLVM previously used knowledge of a single constant panic location to make the failure path of a function smaller.
We've not yet had any reports of this and some ad-hoc measurements don't show any difference. This matches my mental model of LLVM's ability to optimize calling conventions which is "very expensive magic". I'm open to ideas for how to better assess this, including "wait and see".
TLDR Re (2) and (3),
Location
s are 24 bytes when size_of::<usize>() == size_of::<u64>()
and we don't currently measure how many we encode. We should put these in their own section to make it easier to measure.
Which filenames do we encode? In practice: probably all source files. We should put these in their own section too.