Status: New
Owner: ----

New issue 2759 by weiliang...@gmail.com: Performance regression of StringReplace function
http://code.google.com/p/v8/issues/detail?id=2759

Test case:
function test () {
    var string = "scDfce";
    string = string.replace(/\r\n/g,"\n");
    return string;
}

var start = new Date();
for (var i = 0; i < 1e7; i += 1) {
    test();
}
var end = new Date();
print(end - start);


The regression is caused by r15337 (https://codereview.chromium.org/17827005). The remove of ZoneScope increase the memory allocation/release overhead in the runtime function (StringReplaceGlobalRegExpWithString/StringReplaceGlobalAtomRegExpWithString) used by StringReplace.

[~]$ ./d8.15335 replace.js
1519
[~]$ ./d8.15337 replace.js
4847

More than 3X slow

V8 prof output as below
 [JavaScript]:
   ticks  total  nonlib   name
    177    3.9%    3.9%  LazyCompile: *<anonymous> replace.js:1
    169    3.7%    3.7%  LazyCompile: *replace native string.js:212
     55    1.2%    1.2%  Stub: CEntryStub
     47    1.0%    1.0%  LazyCompile: *ToInteger native runtime.js:597

 [C++]:
   ticks  total  nonlib   name
    995   21.8%   21.8%  _int_malloc
    866   19.0%   19.0%  _int_free
    600   13.1%   13.2%  __GI___libc_malloc
339 7.4% 7.4% v8::internal::Runtime_StringReplaceGlobalRegExpWithString(int, v8::internal::Object**, v8::internal::Isolate*)
    255    5.6%    5.6%  v8::internal::Zone::NewExpand(int)
    162    3.5%    3.6%  v8::internal::String::GetFlatContent()
    156    3.4%    3.4%  v8::internal::Zone::~Zone()
94 2.1% 2.1% v8::internal::MaybeObject* v8::internal::StringReplaceGlobalAtomRegExpWithString<v8::internal::SeqOneByteString>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::String>, v8::internal::Handle<v8::internal::JSRegExp>, v8::internal::Handle<v8::internal::String>, v8::internal::Handle<v8::internal::JSArray>) 88 1.9% 1.9% v8::internal::CompiledReplacement::Compile(v8::internal::Handle<v8::internal::String>, int, int) 73 1.6% 1.6% v8::internal::FindStringIndicesDispatch(v8::internal::Isolate*, v8::internal::String*, v8::internal::String*, v8::internal::ZoneList<int>*, unsigned int, v8::internal::Zone*) 72 1.6% 1.6% v8::internal::StringSearch<unsigned char, unsigned char>::LinearSearch(v8::internal::StringSearch<unsigned char, unsigned char>*, v8::internal::Vector<unsigned char const>, int)
     72    1.6%    1.6%  __x86.get_pc_thunk.bx
67 1.5% 1.5% void v8::internal::FindStringIndices<unsigned char, unsigned char>(v8::internal::Isolate*, v8::internal::Vector<unsigned char const>, v8::internal::Vector<unsigned char const>, v8::internal::ZoneList<int>*, unsigned int, v8::internal::Zone*)
     52    1.1%    1.1%  cfree
     49    1.1%    1.1%  v8::internal::Zone::Zone(v8::internal::Isolate*)




--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
--
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to