<?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>76592</bug_id>
          
          <creation_ts>2012-01-18 17:48:17 -0800</creation_ts>
          <short_desc>[v8]Low efficiency of writing long string in npruntime infrastructure</short_desc>
          <delta_ts>2012-01-18 23:52:49 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>New Bugs</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></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Li Yin">li.yin</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>abarth</cc>
    
    <cc>japhet</cc>
    
    <cc>webkit.review.bot</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>538358</commentid>
    <comment_count>0</comment_count>
    <who name="Li Yin">li.yin</who>
    <bug_when>2012-01-18 17:48:17 -0800</bug_when>
    <thetext>[v8]Low efficiency of writing long string in npruntime infrastructure</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>538461</commentid>
    <comment_count>1</comment_count>
      <attachid>123069</attachid>
    <who name="Li Yin">li.yin</who>
    <bug_when>2012-01-18 21:40:11 -0800</bug_when>
    <thetext>Created attachment 123069
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>538474</commentid>
    <comment_count>2</comment_count>
    <who name="Li Yin">li.yin</who>
    <bug_when>2012-01-18 21:53:05 -0800</bug_when>
    <thetext>In chromium-gtk mode, when the big string was transported from web page to plug-in through invoke function, the elapsed time is too long. I found the root cause was that the time of WriteUtf8 operation was too expensive, when the data type of String was ConsString.

Pseudo-code in JavaScript side:
var str=&quot;&quot;;
var num=1024*1024;
for(var i=0; i&lt;num; i++)
    str+=&quot;A&quot;;
plugin_object.writeString(str);

Suppose that plugin_object is a plugin object, and has the function &quot;writeString&quot; in plug-in, although the this function could do nothing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>538476</commentid>
    <comment_count>3</comment_count>
    <who name="Li Yin">li.yin</who>
    <bug_when>2012-01-18 21:55:33 -0800</bug_when>
    <thetext>Specifying the WriteOptions to HINT_MANY_WRITES_EXPECTED in the calling of WriteUtf8,
the efficiency of WriteUtf8 can be greatly improved. 
On the other hand, it almost has no negative effect for short sting.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>538477</commentid>
    <comment_count>4</comment_count>
      <attachid>123069</attachid>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-01-18 21:55:47 -0800</bug_when>
    <thetext>Comment on attachment 123069
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=123069&amp;action=review

Looks reasonable.  A couple nits below.  Thanks for the patch!

&gt; Source/WebCore/ChangeLog:9
&gt; +        Reviewed by NOBODY (OOPS!).
&gt; +
&gt; +        * bindings/v8/V8NPUtils.cpp:
&gt; +        (WebCore::convertV8ObjectToNPVariant):

Can you say something about what gets faster and by how much?  That&apos;s useful information to have in the ChangeLog.

&gt; Source/WebCore/bindings/v8/V8NPUtils.cpp:69
&gt; +        if (!utf8Chars)
&gt; +            return;

in WebKit, malloc crashes if it can&apos;t allocated memory, so this null check isn&apos;t needed.

&gt; Source/WebCore/bindings/v8/V8NPUtils.cpp:70
&gt; +        str-&gt;WriteUtf8(utf8Chars, length, 0, 1);

Can we use HINT_MANY_WRITES_EXPECTED rather than 1 as the fourth parameter?  As-is it&apos;s hard to know what the 1 means.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>538487</commentid>
    <comment_count>5</comment_count>
    <who name="Li Yin">li.yin</who>
    <bug_when>2012-01-18 22:19:12 -0800</bug_when>
    <thetext>1. The efficiency will be improved by 300 times in the best case, when the size of string reaches 1MB.

2. HINT_MANY_WRITES_EXPECTED is internal data type in the class, it can&apos;t be accessed in the V8NPUtils.cpp.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>538488</commentid>
    <comment_count>6</comment_count>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-01-18 22:23:04 -0800</bug_when>
    <thetext>&gt; 2. HINT_MANY_WRITES_EXPECTED is internal data type in the class, it can&apos;t be accessed in the V8NPUtils.cpp.

You can&apos;t write v8::String::HINT_MANY_WRITES_EXPECTED ?  It looks like it&apos;s declared public in v8.h.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>538495</commentid>
    <comment_count>7</comment_count>
      <attachid>123076</attachid>
    <who name="Li Yin">li.yin</who>
    <bug_when>2012-01-18 22:53:36 -0800</bug_when>
    <thetext>Created attachment 123076
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>538498</commentid>
    <comment_count>8</comment_count>
    <who name="Li Yin">li.yin</who>
    <bug_when>2012-01-18 22:57:15 -0800</bug_when>
    <thetext>

(In reply to comment #6)
&gt; &gt; 2. HINT_MANY_WRITES_EXPECTED is internal data type in the class, it can&apos;t be accessed in the V8NPUtils.cpp.
&gt; 
&gt; You can&apos;t write v8::String::HINT_MANY_WRITES_EXPECTED ?  It looks like it&apos;s declared public in v8.h.

Yeah, thanks for your reminding and review, and I committed the new patch based on your suggestion, please check it. 
Thanks.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>538499</commentid>
    <comment_count>9</comment_count>
      <attachid>123076</attachid>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-01-18 22:57:32 -0800</bug_when>
    <thetext>Comment on attachment 123076
Patch

Looks great.  Thanks!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>538523</commentid>
    <comment_count>10</comment_count>
      <attachid>123076</attachid>
    <who name="WebKit Review Bot">webkit.review.bot</who>
    <bug_when>2012-01-18 23:52:44 -0800</bug_when>
    <thetext>Comment on attachment 123076
Patch

Clearing flags on attachment: 123076

Committed r105389: &lt;http://trac.webkit.org/changeset/105389&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>538524</commentid>
    <comment_count>11</comment_count>
    <who name="WebKit Review Bot">webkit.review.bot</who>
    <bug_when>2012-01-18 23:52:49 -0800</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>123069</attachid>
            <date>2012-01-18 21:40:11 -0800</date>
            <delta_ts>2012-01-18 22:53:16 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>bug-76592-20120120134034.patch</filename>
            <type>text/plain</type>
            <size>1811</size>
            <attacher name="Li Yin">li.yin</attacher>
            
              <data encoding="base64">SW5kZXg6IFNvdXJjZS9XZWJDb3JlL0NoYW5nZUxvZwo9PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBTb3VyY2UvV2Vi
Q29yZS9DaGFuZ2VMb2cJKHJldmlzaW9uIDEwNTM3NykKKysrIFNvdXJjZS9XZWJDb3JlL0NoYW5n
ZUxvZwkod29ya2luZyBjb3B5KQpAQCAtMSwzICsxLDEzIEBACisyMDEyLTAxLTE5ICBMaSBZaW4g
IDxsaS55aW5AaW50ZWwuY29tPgorCisgICAgICAgIFt2OF0gTG93IGVmZmljaWVuY3kgb2Ygd3Jp
dGluZyBsb25nIHN0cmluZyBmcm9tIHdlYiBhcHBsaWNhdGlvbiB0byBwbHVnaW4uCisgICAgICAg
IGh0dHBzOi8vYnVncy53ZWJraXQub3JnL3Nob3dfYnVn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plY3Qt
PlRvU3RyaW5nKCk7CisgICAgICAgIGludCBsZW5ndGggPSBzdHItPlV0ZjhMZW5ndGgoKSArIDE7
CiAgICAgICAgIGNoYXIqIHV0ZjhDaGFycyA9IHJlaW50ZXJwcmV0X2Nhc3Q8Y2hhcio+KG1hbGxv
YyhsZW5ndGgpKTsKLSAgICAgICAgbWVtY3B5KHV0ZjhDaGFycywgKnV0ZjgsIGxlbmd0aCk7Ci0g
ICAgICAgIFNUUklOR05fVE9fTlBWQVJJQU5UKHV0ZjhDaGFycywgdXRmOC5sZW5ndGgoKSwgKnJl
c3VsdCk7CisgICAgICAgIGlmICghdXRmOENoYXJzKQorICAgICAgICAgICAgcmV0dXJuOworICAg
ICAgICBzdHItPldyaXRlVXRmOCh1dGY4Q2hhcnMsIGxlbmd0aCwgMCwgMSk7CisgICAgICAgIFNU
UklOR05fVE9fTlBWQVJJQU5UKHV0ZjhDaGFycywgbGVuZ3RoLTEsICpyZXN1bHQpOwogICAgIH0g
ZWxzZSBpZiAob2JqZWN0LT5Jc09iamVjdCgpKSB7CiAgICAgICAgIERPTVdpbmRvdyogd2luZG93
ID0gVjhQcm94eTo6cmV0cmlldmVXaW5kb3coVjhQcm94eTo6Y3VycmVudENvbnRleHQoKSk7CiAg
ICAgICAgIE5QT2JqZWN0KiBucG9iamVjdCA9IG5wQ3JlYXRlVjhTY3JpcHRPYmplY3QoMCwgdjg6
OkhhbmRsZTx2ODo6T2JqZWN0Pjo6Q2FzdChvYmplY3QpLCB3aW5kb3cpOwo=
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>123076</attachid>
            <date>2012-01-18 22:53:36 -0800</date>
            <delta_ts>2012-01-18 23:52:44 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>bug-76592-20120120145359.patch</filename>
            <type>text/plain</type>
            <size>1921</size>
            <attacher name="Li Yin">li.yin</attacher>
            
              <data encoding="base64">SW5kZXg6IFNvdXJjZS9XZWJDb3J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