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

Issue 5556012: Speed up quoting of JSON strings by allocating a string that is big enough... (Closed)

Created:
10 years ago by Erik Corry
Modified:
9 years, 7 months ago
CC:
v8-dev
Visibility:
Public.

Description

Speed up quoting of JSON strings by allocating a string that is big enough and then trimming it when the length is known. This way we only have to traverse the input once. Committed: http://code.google.com/p/v8/source/detail?r=5951

Patch Set 1 #

Total comments: 4
Unified diffs Side-by-side diffs Delta from patch set Stats (+138 lines, -78 lines) Patch
M src/runtime.cc View 3 chunks +120 lines, -77 lines 4 comments Download
M src/spaces.h View 1 chunk +5 lines, -0 lines 0 comments Download
M src/spaces-inl.h View 2 chunks +13 lines, -1 line 0 comments Download

Messages

Total messages: 3 (0 generated)
Erik Corry
10 years ago (2010-12-07 17:15:22 UTC) #1
Vyacheslav Egorov (Chromium)
LGTM http://codereview.chromium.org/5556012/diff/1/src/runtime.cc File src/runtime.cc (right): http://codereview.chromium.org/5556012/diff/1/src/runtime.cc#newcode4596 src/runtime.cc:4596: static const byte JsonQuoteLengths[kQuoteTableLength] = { I do ...
10 years ago (2010-12-08 10:51:31 UTC) #2
Erik Corry
10 years ago (2010-12-08 16:35:56 UTC) #3
http://codereview.chromium.org/5556012/diff/1/src/runtime.cc
File src/runtime.cc (right):

http://codereview.chromium.org/5556012/diff/1/src/runtime.cc#newcode4596
src/runtime.cc:4596: static const byte JsonQuoteLengths[kQuoteTableLength] = {
On 2010/12/08 10:51:31, Vyacheslav Egorov wrote:
> I do not like subtle connection between string above and this array.
> 
> It's excruciatingly difficult to check correctness (4 in a row vs. 8 in a
row).
> 
> Can we change it somehow?
> 
Changed the string above so it is also 8 per line, to make visual checking
easier.

http://codereview.chromium.org/5556012/diff/1/src/runtime.cc#newcode4710
src/runtime.cc:4710: write_cursor[0] = replacement[0];
On 2010/12/08 10:51:31, Vyacheslav Egorov wrote:
> Some replacements have len == 1.
> 
> Why we optimistically write two characters for them and them move write cursor
> by 1? This is really confusing.

It is in order to remove mispredicted branches in this very hot inner loop. 
However measurements show that the extra writes almost cancel out the benefit of
not having mispredicts so I will remove this trick it for clarity.

Powered by Google App Engine
This is Rietveld 408576698