<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>117586</bug_id>
          
          <creation_ts>2013-06-13 03:23:44 -0700</creation_ts>
          <short_desc>Optimize String::fromUTF8 for ASCII</short_desc>
          <delta_ts>2013-06-22 19:48:25 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Web Template Framework</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>BlinkMergeCandidate</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Gyuyoung Kim">gyuyoung.kim</reporter>
          <assigned_to name="Gyuyoung Kim">gyuyoung.kim</assigned_to>
          <cc>benjamin</cc>
    
    <cc>cmarcelo</cc>
    
    <cc>commit-queue</cc>
    
    <cc>rniwa</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>899965</commentid>
    <comment_count>0</comment_count>
    <who name="Gyuyoung Kim">gyuyoung.kim</who>
    <bug_when>2013-06-13 03:23:44 -0700</bug_when>
    <thetext>We probably need to consider to merge with https://src.chromium.org/viewvc/blink?view=rev&amp;revision=152243. Current String::fromUTF8() implementation converts 8 bit ASCII character into 16 bit. Instead of always trying to convert into a 16 bit buffer, we can add a call to charactersAreAllASCII. In the common case when characters are ASCII, we directly copy it into an 8 bit string buffer.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>899969</commentid>
    <comment_count>1</comment_count>
      <attachid>204566</attachid>
    <who name="Gyuyoung Kim">gyuyoung.kim</who>
    <bug_when>2013-06-13 03:26:38 -0700</bug_when>
    <thetext>Created attachment 204566
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>900141</commentid>
    <comment_count>2</comment_count>
      <attachid>204566</attachid>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2013-06-13 09:52:40 -0700</bug_when>
    <thetext>Comment on attachment 204566
Patch

Looks good.  Thanks for porting this over!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>900144</commentid>
    <comment_count>3</comment_count>
      <attachid>204566</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2013-06-13 09:56:19 -0700</bug_when>
    <thetext>Comment on attachment 204566
Patch

Clearing flags on attachment: 204566

Committed r151556: &lt;http://trac.webkit.org/changeset/151556&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>900145</commentid>
    <comment_count>4</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2013-06-13 09:56:22 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>900926</commentid>
    <comment_count>5</comment_count>
    <who name="Benjamin Poulain">benjamin</who>
    <bug_when>2013-06-16 19:36:10 -0700</bug_when>
    <thetext>We looked into this change but I was unconvinced.

Did you get actual performance numbers? If not, please get numbers and follow up (or revert).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>900927</commentid>
    <comment_count>6</comment_count>
    <who name="Gyuyoung Kim">gyuyoung.kim</who>
    <bug_when>2013-06-16 20:12:22 -0700</bug_when>
    <thetext>(In reply to comment #5)
&gt; We looked into this change but I was unconvinced.
&gt; 
&gt; Did you get actual performance numbers? If not, please get numbers and follow up (or revert).

It looks Adam Barth didn&apos;t get meaning performance number. Anyway, I will try to get performance number. If failed, let&apos;s consider to revert this patch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>902039</commentid>
    <comment_count>7</comment_count>
    <who name="Ryosuke Niwa">rniwa</who>
    <bug_when>2013-06-20 00:21:28 -0700</bug_when>
    <thetext>(In reply to comment #6)
&gt; (In reply to comment #5)
&gt; &gt; We looked into this change but I was unconvinced.
&gt; &gt; 
&gt; &gt; Did you get actual performance numbers? If not, please get numbers and follow up (or revert).
&gt; 
&gt; It looks Adam Barth didn&apos;t get meaning performance number. Anyway, I will try to get performance number. If failed, let&apos;s consider to revert this patch.

Did you get a number?  I did look into this but it was an overall perf. regression.

I&apos;d like to know on which test you saw a performance improvement.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>902042</commentid>
    <comment_count>8</comment_count>
    <who name="Gyuyoung Kim">gyuyoung.kim</who>
    <bug_when>2013-06-20 00:44:29 -0700</bug_when>
    <thetext>(In reply to comment #7)
&gt; (In reply to comment #6)
&gt; &gt; (In reply to comment #5)
&gt; &gt; &gt; We looked into this change but I was unconvinced.
&gt; &gt; &gt; 
&gt; &gt; &gt; Did you get actual performance numbers? If not, please get numbers and follow up (or revert).
&gt; &gt; 
&gt; &gt; It looks Adam Barth didn&apos;t get meaning performance number. Anyway, I will try to get performance number. If failed, let&apos;s consider to revert this patch.
&gt; 
&gt; Did you get a number?  I did look into this but it was an overall perf. regression.
&gt; 
&gt; I&apos;d like to know on which test you saw a performance improvement.

Sorry. I don&apos;t get meaningful number on this patch yet. If there is a performance regression after this patch, I don&apos;t mind to roll this patch out for now. When I get a number or better number, I will pong you guys.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>902076</commentid>
    <comment_count>9</comment_count>
    <who name="Gyuyoung Kim">gyuyoung.kim</who>
    <bug_when>2013-06-20 03:43:58 -0700</bug_when>
    <thetext>I simply run sunspider test w/ and w/o this patch. However, I fail to get a meaningful difference between them. String tests of sunspider took 45 ms ~ 47 ms generally both of them.

string : 47.1 ms
 - base64: 3.7 ms
 - fasta: 8.4 ms
 - tagcloud: 9.2 ms
 - unpack-code: 20.5 ms
 - validate-input: 5.3 ms

I&apos;m not sure if sunspider is correct tool for this patch. However, it shows this patch doesn&apos;t improve js string performance at least. I will try to get a number a little further.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>902170</commentid>
    <comment_count>10</comment_count>
    <who name="Benjamin Poulain">benjamin</who>
    <bug_when>2013-06-20 09:07:45 -0700</bug_when>
    <thetext>(In reply to comment #9)
&gt; I&apos;m not sure if sunspider is correct tool for this patch. However, it shows this patch doesn&apos;t improve js string performance at least. I will try to get a number a little further.

I think a good test would be checking how much time we spend in this function when loading a non-latin1 website.

For example, take a well known Korean website, can it. Load the canned version with and without the patch and measure the function time with DTrace.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>902478</commentid>
    <comment_count>11</comment_count>
    <who name="Gyuyoung Kim">gyuyoung.kim</who>
    <bug_when>2013-06-21 01:43:42 -0700</bug_when>
    <thetext>(In reply to comment #10)
 
&gt; For example, take a well known Korean website, can it. Load the canned version with and without the patch and measure the function time with DTrace.

I measure total execution time on String::fromUTF8() using &quot;struct timeval&quot;. I used popular korean web sites (http://www.naver.com and http://www.daum.net)

I measure the execution time with entry point and entrance point. I calculated the time gap using both of them. Result below shows total execution time in fromUTF8() until finishing front page loading. 


When using this patch,
1. naver : 250 us ~ 300 us
2. daum : 200 us ~ 250 us

When using previous one,
1. naver : 1,160 us ~ 1,300 us
2. daum : 800 us ~ 900 us

According to this profiling, this patch looks reduce execution time by about 2 ~ 3 times.

If there is any problems or mistakes in my test, please let me know.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>902819</commentid>
    <comment_count>12</comment_count>
    <who name="Benjamin Poulain">benjamin</who>
    <bug_when>2013-06-22 19:48:25 -0700</bug_when>
    <thetext>Sounds good to me then.

Thank you for getting the numbers.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>204566</attachid>
            <date>2013-06-13 03:26:38 -0700</date>
            <delta_ts>2013-06-13 09:56:19 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-117586-20130613192456.patch</filename>
            <type>text/plain</type>
            <size>3080</size>
            <attacher name="Gyuyoung Kim">gyuyoung.kim</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMTUxNTM0CmRpZmYgLS1naXQgYS9Tb3VyY2UvV1RGL0NoYW5n
ZUxvZyBiL1NvdXJjZS9XVEYvQ2hhbmdlTG9nCmluZGV4IGNmYTU1Nzk3NDdlNzY3ZWE5MDc3YzA0
Njk1NmRhMTMyY2M1NDk4MmUuLmM1YmJiNjU4NThkM2IyNDUyZjg4MjM1ZjM0ZjhlOWM1OTYwNDEx
MTQgMTAwNjQ0Ci0tLSBhL1NvdXJjZS9XVEYvQ2hhbmdlTG9nCisrKyBiL1NvdXJjZS9XVEYvQ2hh
bmdlTG9nCkBAIC0xLDMgKzEsMTkgQEAKKzIwMTMtMDYtMTIgIEd5dXlvdW5nIEtpbSAgPGd5dXlv
dW5nLmtpbUBzYW1zdW5nLmNvbT4KKworICAgICAgICBPcHRpbWl6ZSBTdHJpbmc6OmZyb21VVEY4
IGZvciBBU0NJSQorICAgICAgICBodHRwczovL2J1Z3Mud2Via2l0Lm9yZy9zaG93X2J1Zy5jZ2k/
aWQ9MTE3NTg2CisKKyAgICAgICAgUmV2aWV3ZWQgYnkgTk9CT0RZIChPT1BTISkuCisKKyAgICAg
ICAgRnJvbSBCbGluayByMTUyMjQzIGJ5IDxhYmFydGhAY2hyb21pdW0ub3JnPgorCisgICAgICAg
IEN1cnJlbnQgU3RyaW5nOjpmcm9tVVRGOCgpIGltcGxlbWVudGF0aW9uIGNvbnZlcnRzIDggYml0
IEFTQ0lJIGNoYXJhY3RlciBpbnRvIDE2IGJpdC4KKyAgICAgICAgSW5zdGVhZCBvZiBhbHdheXMg
dHJ5aW5nIHRvIGNvbnZlcnQgaW50byBhIDE2IGJpdCBidWZmZXIsIHdlIGNhbiB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