Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(429)

Issue 8390004: Improve WriteUtf8 and WriteAscii. (Closed)

Created:
9 years, 1 month ago by Yang
Modified:
8 years, 5 months ago
Reviewers:
Erik Corry
CC:
v8-dev
Visibility:
Public.

Description

Improve WriteUtf8 and WriteAscii.

Patch Set 1 #

Total comments: 3

Patch Set 2 : Improved and added test. #

Patch Set 3 : Removed heuristic for flattening #

Unified diffs Side-by-side diffs Delta from patch set Stats (+39 lines, -7 lines) Patch
M src/api.cc View 1 2 4 chunks +21 lines, -7 lines 0 comments Download
M test/cctest/test-api.cc View 1 2 chunks +18 lines, -0 lines 0 comments Download

Messages

Total messages: 5 (0 generated)
Yang
Please take a look. http://codereview.chromium.org/8390004/diff/1/src/api.cc File src/api.cc (right): http://codereview.chromium.org/8390004/diff/1/src/api.cc#newcode3649 src/api.cc:3649: } Flatten as early as ...
9 years, 1 month ago (2011-10-25 16:21:44 UTC) #1
Erik Corry
http://codereview.chromium.org/8390004/diff/1/src/api.cc File src/api.cc (right): http://codereview.chromium.org/8390004/diff/1/src/api.cc#newcode3729 src/api.cc:3729: if (str->IsAsciiRepresentation()) { On 2011/10/25 16:21:45, Yang wrote: > ...
9 years, 1 month ago (2011-10-25 19:21:22 UTC) #2
Yang
Turns out my changes were not well tested to begin with. I added some tests ...
9 years, 1 month ago (2011-10-26 09:43:52 UTC) #3
Yang
On 2011/10/26 09:43:52, Yang wrote: > Turns out my changes were not well tested to ...
9 years, 1 month ago (2011-11-09 12:12:53 UTC) #4
Yang
8 years, 11 months ago (2012-01-16 10:59:43 UTC) #5
On 2011/11/09 12:12:53, Yang wrote:
> On 2011/10/26 09:43:52, Yang wrote:
> > Turns out my changes were not well tested to begin with. I added some tests
> and
> > fixed the issues.
> > 
> > The null embedding has been fixed by an additional loop doing a replace. It
is
> > still faster this way. I gathered some data. Using WriteAscii on a cons with
> > length 2^28 and 28 levels, the old version takes 1780ms, the new version
takes
> > 1140ms. When using WriteAscii on a cons with length 2^8 and 8 levels a total
> of
> > 2^20 times, the old version takes 1700ms, the new version takes 990ms.
> 
> *gentle nudge*

Ping on this.  This fast path would improve some things for nodejs.

The effectiveness of this patch can be tested with this, appended to test-api.cc

==================
#include <ctime>

TEST(ConsWrite) {
  v8::HandleScope scope;
  LocalContext env;
  v8::Local<v8::Value> result;
  const char* cons = "c = 'a'; for (var i=0; i < 28; i++) c = c+c;";

  v8::Local<v8::String> string = v8::String::Cast(*CompileRun(cons));

  char* buffer = new char[1 << 28];
  clock_t start = clock();
  string->WriteAscii(buffer, 0, (1 << 28) -1);
  clock_t stop = clock();
  printf("%f milliseconds\n", (double) (stop - start) / CLOCKS_PER_SEC * 1000);

  start = clock();
  string->WriteAscii(buffer, 0, (1 << 28) -1,
                     v8::String::HINT_MANY_WRITES_EXPECTED);
  stop = clock();
  printf("%f milliseconds\n", (double) (stop - start) / CLOCKS_PER_SEC * 1000);
}
==================

The result I get is
- w/o patch

1780.000000 milliseconds
1550.000000 milliseconds

- w/ patch

1180.000000 milliseconds
1220.000000 milliseconds

Powered by Google App Engine
This is Rietveld 408576698