Linux perf can record samples by build ID instead of virtual address
Ian Rogers's series lets samples carry a file identity and offset, so perf no longer has to reconstruct a process address space just to name a symbol.
Ian Rogers has posted a fourth revision of kernel and userspace changes that let Linux perf samples carry a build ID and a file offset instead of a virtual address. The point is symbolization: today, turning a sampled instruction pointer into a function name depends on synthesized mmap records that reconstruct a process's address space, including the effects of address-space randomization. Recording the binary's identity and the offset inside that file makes that reconstruction optional.
The pair is larger than a pointer, so the new sample formats are a choice, not a replacement. Synthesis stays on by default, because perf still has to turn a build ID into a file on disk. Someone who already knows those IDs, for example through debuginfod, can turn synthesis off. Rogers wrote that the changes exist so users can pick the format "when they believe it is advantageous."
Two new sample bits cover the instruction pointer and the call chain. Call chains do not repeat a full build ID on every frame: unique IDs are packed into a short table, at most 254 per record, and user frames refer to that table plus a file offset. Kernel frames and context markers are left as they are. Resolution of user-space build IDs is deferred out of the sample path, reusing the same build ID and offset lookup the kernel already uses for BPF stack traces. With the new record option, that work is the default.
On the tool side, perf record --buildid-offset asks the kernel for the new formats, and perf inject can rewrite an existing trace: drop user-space mmap events and replace virtual addresses in samples and call chains with build IDs and offsets. Report and script then resolve symbols from that payload. The series is on the kernel BPF list and is not yet merged.