On Sat, Mar 19, 2016 at 09:06:26AM +0100, Alexandre Ratchov wrote: > The browsers problems seem caused by the way pthreads behave; > browsers appear to spin. With the proposed scheduler they spin > less. But the real question is why they spin at all?
Inspired by this comment, I set out to see if I could find *where* the browsers are spinning. "Just build the browsers with profiling instrumentation and look where the time goes when playing a youtube video" I thought. "Easy" I thought. Well no. We build our chrome and firefox with clang, which doesn't support gprof style profiling. Clang does have this -fprofile-instr-generate flag, which throws out some profiling data at runtime, but it appears it is designed to be used by the compiler itself as compile-time optimisation hints[1]. It's not even clear if there is any timing data in there. There's another clang profiling mode which depends upon Linux perf, which is obviously not an option for us. Nevertheless, I decided to try it on the off-chance that clang's profiling data could be useful (and I'm totally accepting that, if it is, I will probably have to write a python script to make sense of the output). Sadly I stumbled at the first hurdle: ---8<--- $ cat a.c #include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { return (EXIT_SUCCESS); } $clang -fprofile-instr-generate a.c -lclang /usr/local/lib/libclang.so.2.0: warning: warning: sprintf() is often misused, please use snprintf() /tmp/a-f91c15.o: In function `__llvm_profile_register_functions': a.c:(.text+0x3c): undefined reference to `__llvm_profile_register_function' /tmp/a-f91c15.o: In function `__llvm_profile_runtime_user': a.c:(.text+0x53): undefined reference to `__llvm_profile_runtime' clang-3.7: error: linker command failed with exit code 1 (use -v to see invocation) --->8--- Any clang afficionados know what is missing here? Or is there a better way to find the spinning code? There has to be a better way. A potential option would be to port and use the profiling portion of [2]. [1] http://clang.llvm.org/docs/UsersManual.html#profile-guided-optimization [2] https://github.com/gperftools/gperftools -- Best Regards Edd Barrett http://www.theunixzoo.co.uk