On Apr 19, 2004, at 2:25 AM, Leopold Toetsch wrote:

Jeff Clites <[EMAIL PROTECTED]> wrote:

This change speeds up the attached benchmark by a factor of 1.86 in the
optimize case (via --optimize, so -Os), or 3.73 in the unoptimized case
(on Mac OS X):

Wheee, that's a lot.

Here's another tiny patch, to let us fast-fail string_equal if we have cached hashval's which don't match. It will only make a difference in some cases (strings of equal length which only differ near the end, and which have cached hashval's), but in those cases the speedup can be a factor of 1.8 (optimized build, benchmark attached).

JEff

Index: src/string.c
===================================================================
RCS file: /cvs/public/parrot/src/string.c,v
retrieving revision 1.195
diff -u -b -r1.195 string.c
--- src/string.c        19 Apr 2004 12:15:15 -0000      1.195
+++ src/string.c        20 Apr 2004 16:40:41 -0000
@@ -1758,6 +1758,11 @@
     else if (!s1->strlen && !s2->strlen) {
         return 0;
     }
+    else if ((s1->hashval != s2->hashval)
+                && (s1->hashval != 0) && (s2->hashval != 0))
+    {
+        return 1;
+    }

 #  if ! DISABLE_GC_DEBUG
     /* It's easy to forget that string comparison can trigger GC */


Attachment: string-equal-timing-hashed.pasm
Description: Binary data

Reply via email to