]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
TCHAIN: avoid calls to search_transtab and return to scheduer by first using tt_fast
authorPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Wed, 11 Apr 2012 21:25:37 +0000 (21:25 +0000)
committerPhilippe Waroquiers <philippe.waroquiers@skynet.be>
Wed, 11 Apr 2012 21:25:37 +0000 (21:25 +0000)
This slightly improves some perf tests (e.g. heap).
Some not explained "real time" slow down of bz2 between trunk/svn tchain
and this patch analyzed with callgrind/cachegrind.
realtime slowdown attributed to Pentium 4 self modifying code unfriendly cache.

(callgrind/cachegrind cache simulation do not understand self modifying
code).

git-svn-id: svn://svn.valgrind.org/valgrind/branches/TCHAIN@12499

coregrind/m_scheduler/scheduler.c

index e52ab7f1aae672f02985278f08e658759d8ab866..09e290801a772e851945b325765943ba6e65400b 100644 (file)
@@ -837,31 +837,35 @@ void run_thread_for_a_while ( /*OUT*/HWord* two_words,
    if (use_alt_host_addr) {
       /* unusual case -- no-redir translation */
       host_code_addr = alt_host_addr;
-      vg_assert(host_code_addr != 0); /* implausible */
    } else {
       /* normal case -- redir translation */
-      AddrH res   = 0;
-      Bool  found = VG_(search_transtab)(
-                       &res, NULL, NULL,
-                       (Addr64)tst->arch.vex.VG_INSTR_PTR,
-                       True/*upd cache -- necessary?*/
-                    );
-      if (found) {
-         host_code_addr = res;
-         vg_assert(host_code_addr != 0); /* implausible */
-      } else {
-         host_code_addr = 0;
+      UInt cno = (UInt)VG_TT_FAST_HASH((Addr)tst->arch.vex.VG_INSTR_PTR);
+      if (LIKELY(VG_(tt_fast)[cno].guest == (Addr)tst->arch.vex.VG_INSTR_PTR))
+         host_code_addr = VG_(tt_fast)[cno].host;
+      else {
+         AddrH res   = 0;
+         /* not found in VG_(tt_fast). Searching here the transtab
+            improves the performance compared to returning directly
+            to the scheduler. */
+         Bool  found = VG_(search_transtab)(&res, NULL, NULL,
+                                            (Addr)tst->arch.vex.VG_INSTR_PTR,
+                                            True/*upd cache*/
+                                            );
+         if (LIKELY(found)) {
+            host_code_addr = res;
+         } else {
+            /* At this point, we know that we intended to start at a
+               normal redir translation, but it was not found.  In
+               which case we can return now claiming it's not
+               findable. */
+            two_words[0] = VG_TRC_INNER_FASTMISS; /* hmm, is that right? */
+            return;
+         }
       }
    }
+   /* We have either a no-redir or a redir translation. */
+   vg_assert(host_code_addr != 0); /* implausible */
 
-   /* At this point, either host_code_addr is nonzero, in which case
-      we're OK, or it's zero, in which case we know that we intended
-      to start at a normal redir translation, but it was not found.
-      In which case we can return now claiming it's not findable. */
-   if (host_code_addr == 0) {
-      two_words[0] = VG_TRC_INNER_FASTMISS; /* hmm, is that right? */
-      return;
-   }
 
    /* there should be no undealt-with signals */
    //vg_assert(VG_(threads)[tid].siginfo.si_signo == 0);