[Webkit-unassigned] [Bug 18666] New: StringImpl::createStrippingNullCharacters has broken optimization

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Apr 21 13:07:02 PDT 2008


           Summary: StringImpl::createStrippingNullCharacters has broken
           Product: WebKit
           Version: 526+ (Nightly build)
          Platform: PC
        OS/Version: Mac OS X 10.5
            Status: UNCONFIRMED
          Severity: Normal
          Priority: P2
         Component: Platform
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: mike at belshe.com

I believe a bug was introduced in Change #29470.

The culprit is:
   foundNull |= ~c;      // This is a one's complement

it should be:
   foundNull |= !c;      // if c is 0, then foundNull is true.

The effect is that the optimization in this function doesn't work, and we
usually take two passes through the entire string.

I went ahead and wrote a test to optimize further.  My main concern was the
copying which is done byte by byte.  I wrote a quick benchmark and tested the
conversion of a 10byte string, a 1000 byte string, and a 10000 byte string.  I
optimized it, and ran in a loop of 100,000 iterations.  

                   10B         1000B            10000B 
CURRENT            95ms        1888ms           20409ms
FIXED VERSION      79ms        1051ms           10007ms
FIXED + MEMCPY     75ms         801ms            9125ms

So, simply fixing the bug doubles the performance of this routine for medium
and large strings.  Switching to the new algorithm (which I'm attaching) gets
another 10%.  Overall, this is negligible on page load performance, however.

Configure bugmail: http://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

More information about the webkit-unassigned mailing list