Performance tweaks around recording threshold.

Instead of per-loop recording threshold counters, this patch uses per-function
recording threshold counters. This allows the code to use plain void* pointers
in searching the keys of the map, reducing the overhead drastically. This is
especially true for instrumented loops located several levels deep in the
heirarchy.