}
 
 static struct rb_root threads;
+static struct thread *last_match;
 
 static struct thread *threads__findnew(pid_t pid)
 {
        struct rb_node *parent = NULL;
        struct thread *th;
 
+       /*
+        * Font-end cache - PID lookups come in blocks,
+        * so most of the time we dont have to look up
+        * the full rbtree:
+        */
+       if (last_match && last_match->pid == pid)
+               return last_match;
+
        while (*p != NULL) {
                parent = *p;
                th = rb_entry(parent, struct thread, rb_node);
 
-               if (th->pid == pid)
+               if (th->pid == pid) {
+                       last_match = th;
                        return th;
+               }
 
                if (pid < th->pid)
                        p = &(*p)->rb_left;
        if (th != NULL) {
                rb_link_node(&th->rb_node, parent, p);
                rb_insert_color(&th->rb_node, &threads);
+               last_match = th;
        }
+
        return th;
 }