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

Issue 9447084: Refactor Pickle Read methods to use higher performance PickleIterator. (Closed)

Created:
8 years, 10 months ago by jbates
Modified:
8 years, 9 months ago
CC:
chromium-reviews
Visibility:
Public.

Description

Refactor Pickle Read methods to use higher performance PickleIterator. There was a lot of redundant error checking and initialization code in all Pickle Read methods because of the void** iterator type. This change replaces the void* iterator with PickleIterator, which encapsulates the read pointer so that less error checking and initialization code is needed for reading. PickleIterator has all the necessary data to do the actual reading. The advantage of having it provide Read methods (as opposed to leaving them solely in the Pickle interface) is that the callers do not need to pass around the const Pickle* once they have a PickleIterator. Followup CLs will refactor the call sites to remove const Pickle* arguments where they are now unnecessary. Then the Pickle::Read* methods can be removed entirely. The alternative approach would have been to change the Pickle::Read methods to non-const and remove the iterator parameter (making Read methods advance an internal read pointer). Unfortunately, the const Read with iterator design is entrenched throughout the chromium code, making this a much more complex change with the same performance outcome. BUG=13108 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=125447

Patch Set 1 #

Patch Set 2 : merge #

Patch Set 3 : jar feedback #

Total comments: 4

Patch Set 4 : jar feedback #

Total comments: 4

Patch Set 5 : darin feedback + merge #

Patch Set 6 : android, win compile #

Patch Set 7 : compile #

Patch Set 8 : compile #

Patch Set 9 : compile #

Patch Set 10 : compile (racing with incoming CLs) #

Patch Set 11 : compile (racing with incoming CLs) #

Patch Set 12 : updated copyright dates #

Patch Set 13 : compile (racing with incoming CLs) #

Unified diffs Side-by-side diffs Delta from patch set Stats (+862 lines, -765 lines) Patch
M base/file_path.h View 1 2 3 4 2 chunks +2 lines, -1 line 0 comments Download
M base/file_path.cc View 1 2 3 4 1 chunk +3 lines, -3 lines 0 comments Download
M base/metrics/histogram.h View 1 2 3 4 3 chunks +3 lines, -2 lines 0 comments Download
M base/metrics/histogram.cc View 1 2 3 4 5 chunks +17 lines, -17 lines 0 comments Download
M base/pickle.h View 1 2 3 4 5 6 7 8 9 10 11 7 chunks +118 lines, -38 lines 0 comments Download
M base/pickle.cc View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +138 lines, -204 lines 0 comments Download
M base/pickle_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 14 chunks +40 lines, -29 lines 0 comments Download
M chrome/browser/automation/url_request_automation_job.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/bookmarks/bookmark_node_data.h View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +3 lines, -2 lines 0 comments Download
M chrome/browser/bookmarks/bookmark_node_data.cc View 1 2 3 4 2 chunks +3 lines, -3 lines 0 comments Download
M chrome/browser/extensions/execute_code_in_tab_function.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/extensions/extension_browser_actions_api.cc View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +2 lines, -2 lines 0 comments Download
M chrome/browser/extensions/extension_messages_browsertest.cc View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +2 lines, -2 lines 0 comments Download
M chrome/browser/extensions/extension_page_actions_module.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/extensions/extension_page_capture_api.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/extensions/extension_tabs_module.cc View 1 2 3 4 5 6 7 8 9 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/importer/profile_import_process_messages.h View 1 2 3 4 7 chunks +7 lines, -7 lines 0 comments Download
M chrome/browser/password_manager/native_backend_kwallet_x.h View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +3 lines, -2 lines 0 comments Download
M chrome/browser/password_manager/native_backend_kwallet_x.cc View 1 2 3 4 2 chunks +2 lines, -2 lines 0 comments Download
M chrome/browser/sessions/base_session_service.cc View 1 2 3 4 3 chunks +3 lines, -3 lines 0 comments Download
M chrome/browser/sessions/compress_data_helper.h View 1 2 3 4 2 chunks +2 lines, -1 line 0 comments Download
M chrome/browser/sessions/compress_data_helper.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M chrome/browser/sessions/compress_data_helper_unittest.cc View 1 2 3 4 3 chunks +3 lines, -3 lines 0 comments Download
M chrome/browser/sessions/session_service.cc View 1 2 3 4 2 chunks +2 lines, -2 lines 0 comments Download
M chrome/browser/ui/views/extensions/browser_action_drag_data.cc View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +2 lines, -2 lines 0 comments Download
M chrome/browser/visitedlink/visitedlink_unittest.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M chrome/common/automation_messages.h View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +2 lines, -2 lines 0 comments Download
M chrome/common/automation_messages.cc View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +2 lines, -2 lines 0 comments Download
M chrome/common/common_param_traits.h View 1 2 3 4 5 6 7 8 9 10 11 4 chunks +5 lines, -3 lines 0 comments Download
M chrome/common/common_param_traits.cc View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +5 lines, -4 lines 0 comments Download
M chrome/common/common_param_traits_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 chunks +12 lines, -12 lines 0 comments Download
M chrome/common/content_settings_pattern.h View 1 2 3 4 2 chunks +3 lines, -1 line 0 comments Download
M chrome/common/content_settings_pattern.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M chrome/common/extensions/extension_messages.h View 1 2 3 4 4 chunks +4 lines, -4 lines 0 comments Download
M chrome/common/extensions/extension_messages.cc View 1 2 3 4 5 6 7 8 9 10 11 6 chunks +6 lines, -6 lines 0 comments Download
M chrome/common/extensions/extension_unpacker.cc View 1 2 3 4 2 chunks +2 lines, -2 lines 0 comments Download
M chrome/common/extensions/user_script.h View 1 2 3 4 5 6 7 8 9 10 11 5 chunks +7 lines, -6 lines 0 comments Download
M chrome/common/extensions/user_script.cc View 1 2 3 4 5 6 7 8 9 10 11 6 chunks +7 lines, -6 lines 0 comments Download
M chrome/common/extensions/user_script_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +2 lines, -2 lines 0 comments Download
M chrome/common/render_messages.h View 1 2 3 4 2 chunks +2 lines, -2 lines 0 comments Download
M chrome/common/render_messages.cc View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +2 lines, -2 lines 0 comments Download
M chrome/renderer/extensions/user_script_slave.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M chrome/test/automation/automation_proxy.cc View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +3 lines, -3 lines 0 comments Download
M chrome/test/automation/automation_proxy_uitest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +1 line, -1 line 0 comments Download
M chrome_frame/cfproxy_support.cc View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +2 lines, -2 lines 0 comments Download
M content/browser/download/base_file.cc View 1 2 3 4 1 chunk +2 lines, -2 lines 0 comments Download
M content/browser/renderer_host/render_sandbox_host_linux.cc View 1 2 3 4 5 6 7 8 9 10 11 10 chunks +15 lines, -10 lines 0 comments Download
M content/browser/renderer_host/render_view_host_impl.cc View 1 2 3 4 5 6 7 8 9 1 chunk +1 line, -1 line 0 comments Download
M content/browser/renderer_host/resource_dispatcher_host_unittest.cc View 1 2 3 4 7 chunks +7 lines, -7 lines 0 comments Download
M content/browser/zygote_host_impl_linux.cc View 1 2 3 4 2 chunks +2 lines, -2 lines 0 comments Download
M content/browser/zygote_main_linux.cc View 1 2 3 4 8 chunks +12 lines, -8 lines 0 comments Download
M content/common/child_process_sandbox_support_impl_linux.cc View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +3 lines, -3 lines 0 comments Download
M content/common/clipboard_messages.h View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M content/common/clipboard_messages.cc View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +2 lines, -2 lines 0 comments Download
M content/common/font_config_ipc_linux.cc View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +3 lines, -3 lines 0 comments Download
M content/common/indexed_db/indexed_db_param_traits.h View 1 2 3 4 3 chunks +3 lines, -3 lines 0 comments Download
M content/common/indexed_db/indexed_db_param_traits.cc View 1 2 3 4 3 chunks +3 lines, -3 lines 0 comments Download
M content/common/mac/attributed_string_coder.h View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +3 lines, -3 lines 0 comments Download
M content/common/mac/attributed_string_coder.mm View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +3 lines, -3 lines 0 comments Download
M content/common/pepper_file_messages.h View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +2 lines, -2 lines 0 comments Download
M content/common/pepper_file_messages.cc View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +2 lines, -2 lines 0 comments Download
M content/common/resource_dispatcher.cc View 1 2 3 4 2 chunks +2 lines, -2 lines 0 comments Download
M content/common/ssl_status_serialization.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M content/ppapi_plugin/ppapi_thread.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M content/public/common/common_param_traits.h View 1 2 3 4 5 6 7 8 9 10 11 17 chunks +17 lines, -17 lines 0 comments Download
M content/public/common/common_param_traits.cc View 1 2 3 4 5 6 7 8 9 10 11 15 chunks +25 lines, -15 lines 0 comments Download
M content/public/common/webkit_param_traits.h View 1 2 3 4 5 6 7 8 9 10 11 11 chunks +12 lines, -12 lines 0 comments Download
M content/public/common/webkit_param_traits.cc View 1 2 3 4 5 6 7 8 9 10 11 8 chunks +9 lines, -9 lines 0 comments Download
M content/renderer/gpu/input_event_filter.cc View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +2 lines, -2 lines 0 comments Download
M content/renderer/render_widget.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M content/test/mock_render_thread.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M crypto/secure_hash.h View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +3 lines, -2 lines 0 comments Download
M crypto/secure_hash_default.cc View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +6 lines, -9 lines 0 comments Download
M crypto/secure_hash_openssl.cc View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +7 lines, -8 lines 0 comments Download
M crypto/secure_hash_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +3 lines, -3 lines 0 comments Download
M gpu/ipc/gpu_command_buffer_traits.h View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M gpu/ipc/gpu_command_buffer_traits.cc View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +2 lines, -2 lines 0 comments Download
M ipc/ipc_channel_posix.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M ipc/ipc_fuzzing_tests.cc View 1 2 3 4 7 chunks +7 lines, -7 lines 0 comments Download
M ipc/ipc_logging.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M ipc/ipc_message.h View 1 2 3 4 1 chunk +2 lines, -1 line 0 comments Download
M ipc/ipc_message.cc View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +2 lines, -2 lines 0 comments Download
M ipc/ipc_message_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 5 chunks +5 lines, -5 lines 0 comments Download
M ipc/ipc_message_utils.h View 1 2 3 4 5 6 7 8 9 47 chunks +76 lines, -53 lines 0 comments Download
M ipc/ipc_message_utils.cc View 1 2 3 4 15 chunks +21 lines, -15 lines 0 comments Download
M ipc/ipc_message_utils_impl.h View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +4 lines, -4 lines 0 comments Download
M ipc/ipc_send_fds_test.cc View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +2 lines, -2 lines 0 comments Download
M ipc/ipc_sync_message.h View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +4 lines, -3 lines 0 comments Download
M ipc/ipc_sync_message.cc View 1 2 3 4 2 chunks +7 lines, -5 lines 0 comments Download
M ipc/ipc_tests.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M ipc/param_traits_macros.h View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +3 lines, -3 lines 0 comments Download
M ipc/param_traits_read_macros.h View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +3 lines, -3 lines 0 comments Download
M net/base/x509_certificate.h View 1 2 3 4 3 chunks +3 lines, -2 lines 0 comments Download
M net/base/x509_certificate.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M net/base/x509_certificate_mac.cc View 1 2 3 4 5 6 1 chunk +1 line, -1 line 0 comments Download
M net/base/x509_certificate_nss.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M net/base/x509_certificate_openssl.cc View 1 2 3 4 5 6 7 8 1 chunk +1 line, -1 line 0 comments Download
M net/base/x509_certificate_unittest.cc View 1 2 3 4 5 6 7 8 9 1 chunk +1 line, -1 line 0 comments Download
M net/base/x509_certificate_win.cc View 1 2 3 4 5 6 1 chunk +1 line, -1 line 0 comments Download
M net/http/http_response_headers.h View 1 2 3 4 2 chunks +2 lines, -1 line 0 comments Download
M net/http/http_response_headers.cc View 1 2 3 4 1 chunk +2 lines, -1 line 0 comments Download
M net/http/http_response_headers_unittest.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M net/http/http_response_info.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M net/http/http_vary_data.h View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +3 lines, -2 lines 0 comments Download
M net/http/http_vary_data.cc View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +2 lines, -2 lines 0 comments Download
M net/socket/ssl_host_info.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M ppapi/proxy/ppapi_param_traits.h View 1 2 3 4 5 6 7 8 9 10 11 15 chunks +15 lines, -15 lines 0 comments Download
M ppapi/proxy/ppapi_param_traits.cc View 1 2 3 4 15 chunks +17 lines, -15 lines 0 comments Download
M ppapi/proxy/serialized_flash_menu.h View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +4 lines, -2 lines 0 comments Download
M ppapi/proxy/serialized_flash_menu.cc View 1 2 3 4 5 6 7 8 9 10 11 5 chunks +8 lines, -5 lines 0 comments Download
M ppapi/proxy/serialized_var.h View 1 2 3 4 3 chunks +4 lines, -2 lines 0 comments Download
M ppapi/proxy/serialized_var.cc View 1 2 3 4 1 chunk +2 lines, -1 line 0 comments Download
M ui/base/clipboard/clipboard_unittest.cc View 1 2 3 4 3 chunks +3 lines, -3 lines 0 comments Download
M ui/base/clipboard/custom_data_helper.cc View 1 2 3 4 5 6 7 8 9 10 11 5 chunks +7 lines, -11 lines 0 comments Download
M ui/base/dragdrop/gtk_dnd_util.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M ui/base/dragdrop/os_exchange_data_win_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +4 lines, -4 lines 0 comments Download
M webkit/fileapi/file_system_directory_database.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M webkit/fileapi/file_system_usage_cache.cc View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +2 lines, -2 lines 0 comments Download
M webkit/glue/glue_serialize.cc View 1 2 3 4 1 chunk +3 lines, -3 lines 0 comments Download
M webkit/glue/npruntime_util.h View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +3 lines, -3 lines 0 comments Download
M webkit/glue/npruntime_util.cc View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +5 lines, -5 lines 0 comments Download
M webkit/glue/webcursor.h View 1 2 3 4 3 chunks +3 lines, -2 lines 0 comments Download
M webkit/glue/webcursor.cc View 1 2 3 4 5 6 7 8 9 10 11 3 chunks +9 lines, -9 lines 0 comments Download
M webkit/glue/webcursor_android.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M webkit/glue/webcursor_aura.cc View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +2 lines, -2 lines 0 comments Download
M webkit/glue/webcursor_gtk.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M webkit/glue/webcursor_mac.mm View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M webkit/glue/webcursor_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 8 chunks +15 lines, -15 lines 0 comments Download
M webkit/glue/webcursor_win.cc View 1 2 3 4 5 6 7 8 9 10 11 2 chunks +3 lines, -3 lines 0 comments Download

Messages

Total messages: 15 (0 generated)
jbates
Starting with you Jim for a high level design review. Feel free to reassign if ...
8 years, 10 months ago (2012-02-27 17:45:51 UTC) #1
jbates
Adding John as well for a high level design review. PTAL
8 years, 10 months ago (2012-02-27 18:12:50 UTC) #2
jar (doing other things)
LGTM You mentioned you were "adding John" but I don't see an additional reviewer or ...
8 years, 9 months ago (2012-02-29 22:04:08 UTC) #3
jbates
Adding darin to cover the majority of the OWNERS. Do I need all the owners ...
8 years, 9 months ago (2012-02-29 23:21:41 UTC) #4
jbates
https://chromiumcodereview.appspot.com/9447084/diff/13002/base/pickle.cc File base/pickle.cc (right): https://chromiumcodereview.appspot.com/9447084/diff/13002/base/pickle.cc#newcode158 base/pickle.cc:158: read_ptr_ = read_end_ptr_ = NULL; On 2012/02/29 22:04:08, jar ...
8 years, 9 months ago (2012-02-29 23:22:25 UTC) #5
darin (slow to review)
I suppose the "Pickle has an internal read cursor" approach could be done even with ...
8 years, 9 months ago (2012-03-02 23:12:34 UTC) #6
jbates
On 2012/03/02 23:12:34, darin wrote: > I suppose the "Pickle has an internal read cursor" ...
8 years, 9 months ago (2012-03-02 23:43:22 UTC) #7
darin (slow to review)
On Fri, Mar 2, 2012 at 3:43 PM, <jbates@chromium.org> wrote: > On 2012/03/02 23:12:34, darin ...
8 years, 9 months ago (2012-03-03 00:03:55 UTC) #8
jbates
On 2012/03/03 00:03:55, darin wrote: > On Fri, Mar 2, 2012 at 3:43 PM, <mailto:jbates@chromium.org> ...
8 years, 9 months ago (2012-03-05 21:55:27 UTC) #9
darin (slow to review)
what's the performance benefit of this change? what kinds of measurements have you done? https://chromiumcodereview.appspot.com/9447084/diff/21002/base/file_path.h ...
8 years, 9 months ago (2012-03-06 18:02:13 UTC) #10
jbates
On 2012/03/06 18:02:13, darin wrote: > what's the performance benefit of this change? what kinds ...
8 years, 9 months ago (2012-03-06 18:23:23 UTC) #11
darin (slow to review)
On Tue, Mar 6, 2012 at 10:23 AM, <jbates@chromium.org> wrote: > On 2012/03/06 18:02:13, darin ...
8 years, 9 months ago (2012-03-06 18:46:17 UTC) #12
jbates
On 2012/03/06 18:46:17, darin wrote: > On Tue, Mar 6, 2012 at 10:23 AM, <mailto:jbates@chromium.org> ...
8 years, 9 months ago (2012-03-06 19:47:29 UTC) #13
jbates
ptal (I mistakenly merged as well in the latest CL. Luckily the only change is ...
8 years, 9 months ago (2012-03-06 22:16:38 UTC) #14
darin (slow to review)
8 years, 9 months ago (2012-03-06 23:03:19 UTC) #15
On Tue, Mar 6, 2012 at 11:47 AM, <jbates@chromium.org> wrote:

> On 2012/03/06 18:46:17, darin wrote:
>
>  On Tue, Mar 6, 2012 at 10:23 AM, <mailto:jbates@chromium.org> wrote:
>>
>
>  > On 2012/03/06 18:02:13, darin wrote:
>> >
>> >> what's the performance benefit of this change?  what kinds of
>> measurements
>> >>
>> > have
>> >
>> >> you done?
>> >>
>> >
>> > For each Read method, the old code is:
>> >
>> > 0000000000000000 <_ZNK6Pickle8ReadLongEPPvPl>:
>> >   0:   48 8b 06                mov    (%rsi),%rax
>> >   3:   48 85 c0                test   %rax,%rax
>> >   6:   74 60                   je     68 <_ZNK6Pickle8ReadLongEPPvPl+**
>>
>> > 0x68>
>> >   8:   48 8b 4f 08             mov    0x8(%rdi),%rcx
>> >   c:   48 39 c8                cmp    %rcx,%rax
>> >   f:   72 1b                   jb     2c <_ZNK6Pickle8ReadLongEPPvPl+**
>>
>> > 0x2c>
>> >  11:   45 31 c0                xor    %r8d,%r8d
>> >  14:   48 85 c9                test   %rcx,%rcx
>> >  17:   74 0e                   je     27 <_ZNK6Pickle8ReadLongEPPvPl+**
>>
>> > 0x27>
>> >  19:   49 89 c9                mov    %rcx,%r9
>> >  1c:   44 8b 01                mov    (%rcx),%r8d
>> >  1f:   4c 03 4f 10             add    0x10(%rdi),%r9
>> >  23:   4f 8d 04 01             lea    (%r9,%r8,1),%r8
>> >  27:   4c 39 c0                cmp    %r8,%rax
>> >  2a:   76 04                   jbe    30 <_ZNK6Pickle8ReadLongEPPvPl+**
>>
>> > 0x30>
>> >  2c:   31 c0                   xor    %eax,%eax
>> >  2e:   c3                      retq
>> >  2f:   90                      nop
>> >  30:   49 89 c1                mov    %rax,%r9
>> >  33:   49 83 c1 08             add    $0x8,%r9
>> >  37:   72 f3                   jb     2c <_ZNK6Pickle8ReadLongEPPvPl+**
>>
>> > 0x2c>
>> >  39:   45 31 c0                xor    %r8d,%r8d
>> >  3c:   48 85 c9                test   %rcx,%rcx
>> >  3f:   90                      nop
>> >  40:   74 0c                   je     4e <_ZNK6Pickle8ReadLongEPPvPl+**
>>
>> > 0x4e>
>> >  42:   49 89 c8                mov    %rcx,%r8
>> >  45:   8b 09                   mov    (%rcx),%ecx
>> >  47:   4c 03 47 10             add    0x10(%rdi),%r8
>> >  4b:   49 01 c8                add    %rcx,%r8
>> >  4e:   4d 39 c1                cmp    %r8,%r9
>> >  51:   77 d9                   ja     2c <_ZNK6Pickle8ReadLongEPPvPl+**
>>
>> > 0x2c>
>> >  53:   48 8b 00                mov    (%rax),%rax
>> >  56:   48 89 02                mov    %rax,(%rdx)
>> >  59:   b8 01 00 00 00          mov    $0x1,%eax
>> >  5e:   48 83 06 08             addq   $0x8,(%rsi)
>> >  62:   c3                      retq
>> >  63:   0f 1f 44 00 00          nopl   0x0(%rax,%rax,1)
>> >  68:   48 8b 47 08             mov    0x8(%rdi),%rax
>> >  6c:   48 03 47 10             add    0x10(%rdi),%rax
>> >  70:   48 89 06                mov    %rax,(%rsi)
>> >  73:   eb 93                   jmp    8 <_ZNK6Pickle8ReadLongEPPvPl+***
>> *0x8>
>>
>> >
>> > With this CL, Read methods look like this:
>> >
>> > 0000000000000000 <_ZN6Pickle9ReadLong2EPl>:
>> >   0:   48 8b 57 28             mov    0x28(%rdi),%rdx
>> >   4:   31 c0                   xor    %eax,%eax
>> >   6:   48 8d 4a 08             lea    0x8(%rdx),%rcx
>> >   a:   48 39 4f 38             cmp    %rcx,0x38(%rdi)
>> >   e:   73 08                   jae    18 <_ZN6Pickle9ReadLong2EPl+0x18>
>> >  10:   f3 c3                   repz retq
>> >  12:   66 0f 1f 44 00 00       nopw   0x0(%rax,%rax,1)
>> >  18:   48 8b 02                mov    (%rdx),%rax
>> >  1b:   48 89 06                mov    %rax,(%rsi)
>> >  1e:   b8 01 00 00 00          mov    $0x1,%eax
>> >  23:   48 83 47 28 08          addq   $0x8,0x28(%rdi)
>> >  28:   c3                      retq
>> >
>> > The code size reduction reduces icache pressure and fewer branches make
>> it
>> > faster. Do we have any micro perf tests that measure this kind of code?
>>
>
>
>
>  OK, but there are very few Read methods.  I don't know of any tests that
>> would
>> specifically help us benchmark this code.
>>
>
>  While this change seems like it could be an improvement, I think it would
>> be
>> helpful to know if this optimization actually manifests itself in terms of
>> any real
>> improvement to the product.
>>
>
> I instrumented the PickleTest.EncodeDecode test (calls Write 7 times with
> various data and then reads it back out) to reread the Pickle many times to
> compare the old Pickle with the new Pickle. I ran each version 8 times and
> took
> the best result for each.
>
> Old code: 1351 ms
> New code: 848 ms
>
> 37% speedup. I'm sure this is a drop in the bucket, but it's a step in the
> right
> direction.
>
>
Well, that is helpful.  At the very least, this is a code simplification
for consumers.

LGTM

-Darin



>
>  -Darin
>>
>
>
>
>  >
>> >
>> >
>> > 
https://chromiumcodereview.**a**ppspot.com/9447084/diff/**<http://appspot.com...
>> >>
>>
>
> 21002/base/file_path.h<https:/**/chromiumcodereview.appspot.**
>
com/9447084/diff/21002/base/**file_path.h<https://chromiumcodereview.appspot.com/9447084/diff/21002/base/file_path.h>
> >
>
>> >> File base/file_path.h (right):
>> >>
>> >
>> >
>> >
https://chromiumcodereview.**a**ppspot.com/9447084/diff/**<http://appspot.com...
>> >
>>
>
> 21002/base/file_path.h#****newcode343<https://**
> chromiumcodereview.appspot.**com/9447084/diff/21002/base/**
>
file_path.h#newcode343<https://chromiumcodereview.appspot.com/9447084/diff/21002/base/file_path.h#newcode343>
> >
>
>> >
>> >> base/file_path.h:343: bool ReadFromPickle(PickleReader* iter);
>> >> sorry to nit pick, but it'd be great if you could rename the parameter
>> to
>> >> 'reader' instead of 'iter'... or maybe go with PickleIterator?
>> >>
>> >
>> > PickleIterator sounds good.
>> >
>> >
>> >
>> > 
https://chromiumcodereview.**a**ppspot.com/9447084/diff/**<http://appspot.com...
>> >>
>>
>
> 21002/base/pickle.h<https://**chromiumcodereview.appspot.**
>
com/9447084/diff/21002/base/**pickle.h<https://chromiumcodereview.appspot.com/9447084/diff/21002/base/pickle.h>
> >
>
>> >> File base/pickle.h (right):
>> >>
>> >
>> >
>> >
https://chromiumcodereview.**a**ppspot.com/9447084/diff/**<http://appspot.com...
>> >
>>
>
> 21002/base/pickle.h#**newcode142<https://**chromiumcodereview.appspot.**
>
com/9447084/diff/21002/base/**pickle.h#newcode142<https://chromiumcodereview.appspot.com/9447084/diff/21002/base/pickle.h#newcode142>
> >
>
>> >
>> >> base/pickle.h:142: bool ReadBool(PickleReader* iter, bool* result)
>> const {
>> >> same nit:  rename 'iter' to 'reader'
>> >>
>> >
>> >
>> >
https://chromiumcodereview.**a**ppspot.com/9447084/diff/**<http://appspot.com...
>> >
>>
>
> 21002/chrome/browser/****bookmarks/bookmark_node_data.****cc<https://**
> chromiumcodereview.appspot.**com/9447084/diff/21002/chrome/**
>
browser/bookmarks/bookmark_**node_data.cc<https://chromiumcodereview.appspot.com/9447084/diff/21002/chrome/browser/bookmarks/bookmark_node_data.cc>
> >
>
>> >
>> >> File chrome/browser/bookmarks/****bookmark_node_data.cc (right):
>> >>
>> >
>> >
>> >
https://chromiumcodereview.**a**ppspot.com/9447084/diff/**<http://appspot.com...
>> >
>>
>
> 21002/chrome/browser/****bookmarks/bookmark_node_data.****cc#newcode57<
> https://**chromiumcodereview.appspot.**com/9447084/diff/21002/chrome/**
>
browser/bookmarks/bookmark_**node_data.cc#newcode57<https://chromiumcodereview.appspot.com/9447084/diff/21002/chrome/browser/bookmarks/bookmark_node_data.cc#newcode57>
> >
>
>> >
>> >> chrome/browser/bookmarks/****bookmark_node_data.cc:57: bool
>> >> BookmarkNodeData::Element::****ReadFromPickle(Pickle* pickle,
>>
>> >> so the idea is to do a follow-up patch that will clean code like this
>> up
>> >> to
>> >>
>> > just
>> >
>> >> pass PickleReader?
>> >>
>> >
>> > Exactly, that's the plan.
>> >
>> >
>>
>
> https://chromiumcodereview.**a**ppspot.com/9447084/%3Chttps://**
>
chromiumcodereview.appspot.**com/9447084/<http://appspot.com/9447084/%3Chttps://chromiumcodereview.appspot.com/9447084/>
> >
>
>> >
>>
>
>
>
https://chromiumcodereview.**appspot.com/9447084/<https://chromiumcodereview....
>

Powered by Google App Engine
This is Rietveld 408576698