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

Issue 10035042: Rewrite base::JSONReader to be 35-40% faster, depending on the input string. (Closed)

Created:
8 years, 8 months ago by Robert Sesek
Modified:
8 years, 7 months ago
CC:
chromium-reviews, cbentzel+watch_chromium.org, erikwright (departed), kkania, mihaip+watch_chromium.org, Aaron Boodman, robertshield, brettw-cc_chromium.org, darin-cc_chromium.org, jshin+watch_chromium.org, tfarina
Visibility:
Public.

Description

Rewrite base::JSONReader to be 35-40% faster, depending on the input string. This change does the following: * Parses the input string and generates the object representation in O(n) time. * Optimizes string decoding by using StringPiece where possible, which also introduces the JSON_DETACHABLE_CHILDREN parser option. * Makes JSONReader a simpler interface by hiding the parser details in an internal JSONParser class. BUG=49212, 111581, 121469 TEST=Hopefully covered by all test suites. New tests added for edge cases. Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=137430

Patch Set 1 #

Total comments: 2

Patch Set 2 : '' #

Total comments: 98

Patch Set 3 : Address comments/fix Win #

Total comments: 38

Patch Set 4 : Really fix Windows, address comments #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1830 lines, -1010 lines) Patch
M base/base.gyp View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
M base/base.gypi View 1 2 3 1 chunk +2 lines, -0 lines 0 comments Download
M base/base_export.h View 1 2 3 1 chunk +4 lines, -0 lines 0 comments Download
M base/debug/trace_event_unittest.cc View 1 chunk +2 lines, -1 line 0 comments Download
A base/json/json_parser.h View 1 2 3 1 chunk +273 lines, -0 lines 0 comments Download
A base/json/json_parser.cc View 1 2 3 1 chunk +972 lines, -0 lines 0 comments Download
A base/json/json_parser_unittest.cc View 1 2 3 1 chunk +293 lines, -0 lines 0 comments Download
M base/json/json_reader.h View 4 chunks +27 lines, -147 lines 0 comments Download
M base/json/json_reader.cc View 5 chunks +28 lines, -652 lines 0 comments Download
M base/json/json_reader_unittest.cc View 1 2 3 12 chunks +186 lines, -148 lines 0 comments Download
M base/string_util.cc View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M base/values.h View 1 2 3 4 chunks +6 lines, -9 lines 0 comments Download
M base/values.cc View 1 2 2 chunks +8 lines, -0 lines 0 comments Download
M chrome/browser/automation/testing_automation_provider.cc View 1 2 3 1 chunk +1 line, -3 lines 0 comments Download
M chrome/browser/extensions/settings/settings_leveldb_storage.cc View 3 chunks +3 lines, -5 lines 0 comments Download
M chrome/browser/prefs/pref_model_associator.cc View 1 2 2 chunks +2 lines, -3 lines 0 comments Download
M chrome/browser/ui/webui/tab_modal_confirm_dialog_webui.cc View 1 2 1 chunk +1 line, -2 lines 0 comments Download
M chrome/common/extensions/api/extension_api.cc View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M chrome/common/extensions/extension_l10n_util_unittest.cc View 1 chunk +5 lines, -5 lines 0 comments Download
M chrome/common/extensions/extension_unpacker_unittest.cc View 1 chunk +2 lines, -2 lines 0 comments Download
M chrome/common/net/gaia/oauth2_mint_token_flow.cc View 1 2 3 1 chunk +1 line, -2 lines 0 comments Download
M chrome/common/net/gaia/oauth2_mint_token_flow_unittest.cc View 1 chunk +1 line, -2 lines 0 comments Download
M chrome/installer/util/master_preferences_unittest.cc View 1 2 3 4 chunks +4 lines, -4 lines 0 comments Download
M chrome/test/base/ui_test_utils.cc View 1 2 3 1 chunk +4 lines, -19 lines 0 comments Download
M net/test/base_test_server.cc View 1 2 1 chunk +1 line, -1 line 0 comments Download
M net/test/spawner_communicator.cc View 1 2 3 1 chunk +1 line, -3 lines 0 comments Download

Messages

Total messages: 14 (0 generated)
Robert Sesek
I apologize for the size…
8 years, 8 months ago (2012-04-18 21:48:53 UTC) #1
Avi (use Gerrit)
https://chromiumcodereview.appspot.com/10035042/diff/1/base/json/json_parser.h File base/json/json_parser.h (right): https://chromiumcodereview.appspot.com/10035042/diff/1/base/json/json_parser.h#newcode37 base/json/json_parser.h:37: // to be used directly; it encapsultes logic that ...
8 years, 8 months ago (2012-04-18 21:57:54 UTC) #2
Robert Sesek
https://chromiumcodereview.appspot.com/10035042/diff/1/base/json/json_parser.h File base/json/json_parser.h (right): https://chromiumcodereview.appspot.com/10035042/diff/1/base/json/json_parser.h#newcode37 base/json/json_parser.h:37: // to be used directly; it encapsultes logic that ...
8 years, 8 months ago (2012-04-18 22:06:36 UTC) #3
Mark Mentovai
https://chromiumcodereview.appspot.com/10035042/diff/1021/base/json/json_parser.cc File base/json/json_parser.cc (right): https://chromiumcodereview.appspot.com/10035042/diff/1021/base/json/json_parser.cc#newcode11 base/json/json_parser.cc:11: #include "base/string_number_conversions.h" '_' < 'p' I would have stayed ...
8 years, 8 months ago (2012-04-19 16:40:11 UTC) #4
tfarina
http://codereview.chromium.org/10035042/diff/1021/base/json/json_parser.h File base/json/json_parser.h (right): http://codereview.chromium.org/10035042/diff/1021/base/json/json_parser.h#newcode57 base/json/json_parser.h:57: virtual ~JSONParser(); nit: I think this doesn't need to ...
8 years, 8 months ago (2012-04-19 22:48:18 UTC) #5
tfarina
http://codereview.chromium.org/10035042/diff/1021/base/json/json_parser.cc File base/json/json_parser.cc (right): http://codereview.chromium.org/10035042/diff/1021/base/json/json_parser.cc#newcode875 base/json/json_parser.cc:875: return base::StringPrintf( nit: base:: here is not necessary as ...
8 years, 8 months ago (2012-04-19 22:54:47 UTC) #6
tfarina
http://codereview.chromium.org/10035042/diff/1021/base/json/json_parser_unittest.cc File base/json/json_parser_unittest.cc (right): http://codereview.chromium.org/10035042/diff/1021/base/json/json_parser_unittest.cc#newcode12 base/json/json_parser_unittest.cc:12: using base::internal::JSONParser; nit: I don't think you need this, ...
8 years, 8 months ago (2012-04-19 22:56:23 UTC) #7
Robert Sesek
So I "resolved" the Windows failures by forcing DETACHABLE_CHILDREN. I'll fix that via the bug ...
8 years, 7 months ago (2012-05-03 15:34:51 UTC) #8
tfarina
http://codereview.chromium.org/10035042/diff/30002/base/json/json_parser.cc File base/json/json_parser.cc (right): http://codereview.chromium.org/10035042/diff/30002/base/json/json_parser.cc#newcode192 base/json/json_parser.cc:192: pos_(0), nit: just curious why did you choose 0 ...
8 years, 7 months ago (2012-05-04 00:25:28 UTC) #9
Mark Mentovai
http://codereview.chromium.org/10035042/diff/30002/base/json/json_parser.cc File base/json/json_parser.cc (right): http://codereview.chromium.org/10035042/diff/30002/base/json/json_parser.cc#newcode41 base/json/json_parser.cc:41: DLOG(1) << "Swap()ing a DictionaryValue inefficiently."; DLOG(1) is DLOG(WARNING). ...
8 years, 7 months ago (2012-05-08 20:19:40 UTC) #10
Robert Sesek
http://codereview.chromium.org/10035042/diff/30002/base/json/json_parser.cc File base/json/json_parser.cc (right): http://codereview.chromium.org/10035042/diff/30002/base/json/json_parser.cc#newcode41 base/json/json_parser.cc:41: DLOG(1) << "Swap()ing a DictionaryValue inefficiently."; On 2012/05/08 20:19:41, ...
8 years, 7 months ago (2012-05-15 16:57:50 UTC) #11
Mark Mentovai
LGTM. I’ve read this enough and I’m satisfied with the few changes I’ve spot-checked.
8 years, 7 months ago (2012-05-15 17:44:38 UTC) #12
Robert Sesek
brettw: Anything else to add? +darin: FYI for base_export.h change On 2012/05/15 17:44:38, Mark Mentovai ...
8 years, 7 months ago (2012-05-15 17:56:27 UTC) #13
brettw
8 years, 7 months ago (2012-05-15 19:30:09 UTC) #14
I'm happy with Mark's review, I didn't look at anything again.

Powered by Google App Engine
This is Rietveld 408576698