From ca986f998bcfd093e6c0bcbd2f145231fde48617 Mon Sep 17 00:00:00 2001 From: Ingo Molnar Date: Wed, 3 Jun 2009 19:59:24 +0200 Subject: [PATCH] --- yaml --- r: 147634 b: refs/heads/master c: eed4dcd443da7a46131ef37c7a389b444905960e h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/Documentation/perf_counter/builtin-report.c | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/[refs] b/[refs] index 702da655bf8c..717eef8a9045 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 44db76c8553c328f4ae02481d77bb3a88ca17645 +refs/heads/master: eed4dcd443da7a46131ef37c7a389b444905960e diff --git a/trunk/Documentation/perf_counter/builtin-report.c b/trunk/Documentation/perf_counter/builtin-report.c index e837bb983dca..33b3b15fb014 100644 --- a/trunk/Documentation/perf_counter/builtin-report.c +++ b/trunk/Documentation/perf_counter/builtin-report.c @@ -229,6 +229,7 @@ static int thread__set_comm(struct thread *self, const char *comm) } static struct rb_root threads; +static struct thread *last_match; static struct thread *threads__findnew(pid_t pid) { @@ -236,12 +237,22 @@ 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; @@ -253,7 +264,9 @@ static struct thread *threads__findnew(pid_t pid) if (th != NULL) { rb_link_node(&th->rb_node, parent, p); rb_insert_color(&th->rb_node, &threads); + last_match = th; } + return th; }