Mike Hommey and I have been working with a linker plugin that uses the callgraph to reorder functions on Linux and Android. One feature of the linker plugin is that it dumps a simplified representation of the callgraph to a text file. The simplified representation is really simple, just edge counts for all the edges in the callgraph. It’s not perfect, since the ordering of caller and callee in the dump file is not always consistent. Also, you get a few spurious functions in there, like __builtin_expect and SSE builtins calling things. (__builtin_expect just provides a hint to the compiler about how to order basic blocks for more cache-friendly control flow; SSE builtins should compile down to single/few instructions and never actually call something at runtime.)
Nevertheless, looking at the file for libxul.so can be illuminating. Actually, it’s probably more illuminating to narrow things down to the edges with 100k+ call counts and demangled function names. Doing that, we can see that:
- We call fgets 115k times. I believe this is solely for the spellchecker’s data. At least we’re not using gets.
- We call floor over a million times. The only caller here is nsRect::ToNearestPixels, which winds up calling floor through the magic of inlining.
- We call the related functions floorf and ceilf over 250k times. The caller here is nsRect::ScaleToOutsidePixels, again through the magic of inlining.
- We have a specialized mozilla::SSE::Convert_ascii_run function; this function gets called 366 times by nsUTF8ToUnicode::Convert. It’s apparently doing a lot of work though; the plugin records that it makes over a million calls to various SSE builtins.
- PL_DHashTableOperate is a pretty busy function with several million calls to it. Big users are GCGraphBuilder::NoteXPCOMChild (167k), nsStaticCaseInsensitiveNameTable::Lookup (100k), RuleHash::EnumerateAllRules (108k), nsPresArena::AllocateBySize (129k) and FramePropertyTable::Get (315k).
- We, um, do a lot of string operations. I won’t enumerate them all here.
- I/O operations get called quite a bit; the profile here is what PGO builds run to get profile feedback.
Anyway, maybe people have already seen all this stuff, but I certainly hadn’t.