New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 599684 link

Starred by 2 users

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 2
Type: Bug
cwp



Sign in to add a comment

base::internal::JSONParser increases from 0.15% to 0.5% during session restore

Project Member Reported by sque@chromium.org, Mar 31 2016

Issue description

According to CWP data (see go/cwp), the percentage of CPU cycles spent in base::internal::JSONParser has increased from 0.15% to 0.35-0.5%. See attached graph.

I don't have deeper insights into which functions have increased but I can keep digging and find out more.

Will assign to the right person when I find that information.
 
JSONParser on session restore.png
68.8 KB View Download

Comment 1 by sque@chromium.org, Mar 31 2016

Labels: Hotlist-Slow

Comment 2 by sque@chromium.org, Apr 1 2016

95% of the samples in JSONParser on ver 7647.84.0 (one of the largest stable channel versions in March) on RESTORE_SESSION come from JSONParser::ConsumeDictionary().

From the above data, 75% of ConsumeDictionary() samples come from line 519 and another 15% come from line 505.

7647 is M48, which branched Nov 13, 2015. The oldest post-branch change to JSONParser is this: http://crrev.com/1538743002

Looking at the patch, lines 519 and 515 correspond to:

 505     if (!ConsumeStringRaw(&key)) {
and
 519     Value* value = ParseNextToken();

Looking at ParseNextToken():
  Value* JSONParser::ParseNextToken() {
    return ParseToken(GetNextToken());
  }

Both ParseToken() and GetNextToken() contain a switch block. It would be useful to look at whether these are compiled as a series of branches as opposed to a table lookup.

Comment 3 by sque@chromium.org, Apr 1 2016

Cc: llozano@chromium.org
Looking at locally compiled code, I see that:

1. ParseToken() has a sequence of comparisons and jumps for its 7-case switch statement.
2. GetNextToken() uses a lookup table.
3. But GetNextToken() also calls EatWhitespaceAndComments() which has a 5-case switch block inside a for loop, and the switch statement is compiled as comparisons and jumps.

I haven't taken a look at ConsumeStringRaw's disassembly but I do see an 11-case switch statement in it.

The statements on lines 505 and 519 are also both in a while loop, meaning that speedups inside the while loop would be multiplied by the number of iterations.

Luis, do you think these could be sped up by using lookup tables for switch statements in more places?

Comment 4 by sque@chromium.org, Jul 26 2016

Cc: chongjiang@chromium.org

Sign in to add a comment