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

Issue 181543004: Optimize VM JSON parser for memory use. (Closed)

Created:
6 years, 10 months ago by Lasse Reichstein Nielsen
Modified:
5 years, 7 months ago
CC:
reviews_dartlang.org, vm-dev_dartlang.org, Søren Gjesse, floitsch
Visibility:
Public.

Description

Optimize VM JSON parser for speed and memory use. Large JSON structures are likely to have many objects with similar structure. This change keeps the structure separate from the values, and a JSON object is a map backed by the structure (the "hidden class") and a list of values. Any modification of the object/map will make it fall back to a linked hash map. Caching might need tweaking (if we want caching at all). The hidden class approach does cause an overhead for unstructured data, but a memory saving for structured data. BUG= http://dartbug.com/16692

Patch Set 1 #

Patch Set 2 : Fix optimisitic optimization. #

Patch Set 3 : Typo in type. #

Total comments: 10

Patch Set 4 : Remove parser optimizations to separate CL. #

Patch Set 5 : Add more tests. #

Total comments: 12
Unified diffs Side-by-side diffs Delta from patch set Stats (+587 lines, -10 lines) Patch
M runtime/lib/convert_patch.dart View 1 2 3 4 8 chunks +499 lines, -6 lines 12 comments Download
M sdk/lib/core/iterable.dart View 2 chunks +3 lines, -4 lines 0 comments Download
M tests/lib/convert/json_test.dart View 1 2 3 4 2 chunks +85 lines, -0 lines 0 comments Download

Messages

Total messages: 13 (0 generated)
Lasse Reichstein Nielsen
6 years, 10 months ago (2014-02-26 16:37:24 UTC) #1
Lasse Reichstein Nielsen
There are several tweaking options: when to switch to maps in the hidden classes, whether ...
6 years, 10 months ago (2014-02-26 16:39:17 UTC) #2
sra1
I think we need a test for the order of keys in the parsed JSON. ...
6 years, 10 months ago (2014-02-26 20:48:42 UTC) #3
sra1
I would split this into two CLs, one for the number and string parsing time ...
6 years, 10 months ago (2014-02-26 21:56:06 UTC) #4
sra1
More DBC https://chromiumcodereview.appspot.com/181543004/diff/40001/runtime/lib/convert_patch.dart File runtime/lib/convert_patch.dart (right): https://chromiumcodereview.appspot.com/181543004/diff/40001/runtime/lib/convert_patch.dart#newcode754 runtime/lib/convert_patch.dart:754: //return new _JsonHiddenClassMap(this, makeListFixedLength(values)).wrapper; Delete comment. https://chromiumcodereview.appspot.com/181543004/diff/40001/runtime/lib/convert_patch.dart#newcode938 ...
6 years, 9 months ago (2014-02-27 04:45:22 UTC) #5
Lasse Reichstein Nielsen
https://codereview.chromium.org/181543004/diff/40001/runtime/lib/convert_patch.dart File runtime/lib/convert_patch.dart (right): https://codereview.chromium.org/181543004/diff/40001/runtime/lib/convert_patch.dart#newcode754 runtime/lib/convert_patch.dart:754: //return new _JsonHiddenClassMap(this, makeListFixedLength(values)).wrapper; Acl, yes. It was an ...
6 years, 9 months ago (2014-02-27 09:10:38 UTC) #6
Lasse Reichstein Nielsen
Moved optimizations to other CL. PTAL
6 years, 9 months ago (2014-03-03 11:44:35 UTC) #7
srdjan
https://codereview.chromium.org/181543004/diff/80001/runtime/lib/convert_patch.dart File runtime/lib/convert_patch.dart (right): https://codereview.chromium.org/181543004/diff/80001/runtime/lib/convert_patch.dart#newcode74 runtime/lib/convert_patch.dart:74: if (key != null) Curly braces missing? https://codereview.chromium.org/181543004/diff/80001/runtime/lib/convert_patch.dart#newcode166 runtime/lib/convert_patch.dart:166: ...
6 years, 9 months ago (2014-03-03 15:12:54 UTC) #8
floitsch
LGTM with minor comments. https://codereview.chromium.org/181543004/diff/80001/runtime/lib/convert_patch.dart File runtime/lib/convert_patch.dart (right): https://codereview.chromium.org/181543004/diff/80001/runtime/lib/convert_patch.dart#newcode74 runtime/lib/convert_patch.dart:74: if (key != null) something's ...
6 years, 9 months ago (2014-03-03 15:36:44 UTC) #9
srdjan
LGTM after addressing comments. Do you see performance numbers?
6 years, 9 months ago (2014-03-03 21:03:55 UTC) #10
Lasse Reichstein Nielsen
The performance change for this CL alone is actually negative (by 5-10%). It does use ...
6 years, 9 months ago (2014-03-06 14:25:02 UTC) #11
sra1
On 2014/03/06 14:25:02, Lasse Reichstein Nielsen wrote: > The performance change for this CL alone ...
6 years, 9 months ago (2014-03-06 18:47:08 UTC) #12
Lasse Reichstein Nielsen
6 years, 9 months ago (2014-03-07 09:26:05 UTC) #13
On 2014/03/06 18:47:08, sra1 wrote:

> We also need a benchmark that uses JSON data, so we know the new Map classes
are
> not slower than the old ones.

They are slower. They pretty much have to be: It's doing the same map lookup,
but instead of directly getting the value, there is a further array lookup with
the index from the map.

This is optimizing for memory, and trying not to regress speed by too much, but
it will certainly be a little slower.
(That said, a benchmark would be great so we can see HOW much slower).

Powered by Google App Engine
This is Rietveld 408576698