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

Issue 2084243004: [WIP][tracing] Add memory dump provider for sync Directory (Closed)

Created:
4 years, 6 months ago by ssid
Modified:
4 years, 1 month ago
CC:
chromium-reviews, sync-reviews_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

[tracing] Add memory dump provider for sync Directory BUG=

Patch Set 1 #

Total comments: 13

Patch Set 2 : Add visitors for memory. #

Patch Set 3 : Add visitors for memory. #

Total comments: 26

Patch Set 4 : Fixes. #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+1518 lines, -453 lines) Patch
M components/sync_driver/glue/sync_backend_host_core.h View 3 chunks +6 lines, -0 lines 0 comments Download
M components/sync_driver/glue/sync_backend_host_core.cc View 1 2 4 chunks +16 lines, -0 lines 0 comments Download
M sync/internal_api/public/base/unique_position.h View 1 2 3 1 chunk +2 lines, -0 lines 0 comments Download
M sync/internal_api/public/sync_manager.h View 2 chunks +9 lines, -0 lines 0 comments Download
M sync/internal_api/public/test/fake_sync_manager.h View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M sync/internal_api/sync_manager_impl.h View 1 chunk +1 line, -0 lines 0 comments Download
M sync/internal_api/sync_manager_impl.cc View 1 chunk +4 lines, -0 lines 0 comments Download
M sync/internal_api/test/fake_sync_manager.cc View 1 2 1 chunk +4 lines, -0 lines 0 comments Download
M sync/protocol/proto_value_conversions.h View 1 2 1 chunk +3 lines, -0 lines 0 comments Download
M sync/protocol/proto_value_conversions.cc View 1 2 3 16 chunks +1299 lines, -452 lines 0 comments Download
M sync/syncable/directory.h View 1 2 chunks +11 lines, -0 lines 0 comments Download
M sync/syncable/directory.cc View 1 2 3 5 chunks +122 lines, -0 lines 3 comments Download
M sync/syncable/entry_kernel.h View 1 3 chunks +6 lines, -0 lines 0 comments Download
M sync/syncable/entry_kernel.cc View 1 1 chunk +1 line, -1 line 0 comments Download
M sync/syncable/parent_child_index.h View 1 2 3 1 chunk +3 lines, -0 lines 0 comments Download
M sync/syncable/parent_child_index.cc View 1 2 3 2 chunks +25 lines, -0 lines 0 comments Download
M tools/metrics/histograms/histograms.xml View 1 2 3 1 chunk +5 lines, -0 lines 0 comments Download

Messages

Total messages: 18 (10 generated)
stanisc
https://codereview.chromium.org/2084243004/diff/10009/sync/syncable/directory.cc File sync/syncable/directory.cc (right): https://codereview.chromium.org/2084243004/diff/10009/sync/syncable/directory.cc#newcode931 sync/syncable/directory.cc:931: PROTO_FIELDS_COUNT * sizeof(sync_pb::EntitySpecifics) + This isn't correct. The actual ...
4 years, 6 months ago (2016-06-24 21:44:35 UTC) #4
ssid
https://codereview.chromium.org/2084243004/diff/10009/sync/syncable/directory.cc File sync/syncable/directory.cc (right): https://codereview.chromium.org/2084243004/diff/10009/sync/syncable/directory.cc#newcode958 sync/syncable/directory.cc:958: .ByteSize(); On 2016/06/24 21:44:35, stanisc wrote: > We've discussed ...
4 years, 6 months ago (2016-06-24 21:56:50 UTC) #5
Nicolas Zea
+Gang FYI
4 years, 5 months ago (2016-06-27 15:22:30 UTC) #7
ssid
I changed the conversions file to give multiple types of result. If i used a ...
4 years, 5 months ago (2016-07-01 22:46:52 UTC) #11
stanisc
Here are my comments from a somewhat cursory review. I didn't have time for a ...
4 years, 5 months ago (2016-07-06 21:50:32 UTC) #12
ssid
Thanks! made changes as suggested. https://codereview.chromium.org/2084243004/diff/110001/sync/internal_api/public/base/unique_position.h File sync/internal_api/public/base/unique_position.h (right): https://codereview.chromium.org/2084243004/diff/110001/sync/internal_api/public/base/unique_position.h#newcode98 sync/internal_api/public/base/unique_position.h:98: size_t compressed_size() const { ...
4 years, 5 months ago (2016-07-19 22:10:35 UTC) #15
ssid
+dskiba
4 years, 5 months ago (2016-07-19 22:11:12 UTC) #17
DmitrySkiba
4 years, 4 months ago (2016-08-09 17:44:10 UTC) #18
So as I understand, there are two parts:

(1) protobuf stuff in proto_value_conversions.cc
(2) C++ stuff (mostly in directory.cc)

Which part is bigger? Can we measure that?

As they are now, the changes are pretty heavy. Do we really need to estimate
EntryKernels? Maybe we can skip them and sacrifice some accuracy?

As for (1), it seems that protobuf supports "arenas":
https://developers.google.com/protocol-buffers/docs/reference/arenas, and arena
class has SpaceUsed() method. I would first look into that.

If that doesn't work (or is hard especially around strings), then I can think of
faking 'Value' classes and compiling them twice, first with 'real' Value
classes, and then with 'fake' ones. I.e. given

std::unique_ptr<base::DictionaryValue> AppSettingsToValue(
    const sync_pb::AppNotificationSettings& proto) {
  std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue());
  SET_BOOL(initial_setup_done);
  SET_BOOL(disabled);
  SET_STR(oauth_client_id);
  return value;
}

we first remove base:: specifier and add a way to override value types:

#if !defined(USING_FAKE_VALUES)
using DictionaryValue = base::DictionaryValue;
#endif

std::unique_ptr<DictionaryValue> AppSettingsToValue(
    const sync_pb::AppNotificationSettings& proto) {
  std::unique_ptr<DictionaryValue> value(new DictionaryValue());
  SET_BOOL(initial_setup_done);
  SET_BOOL(disabled);
  SET_STR(oauth_client_id);
  return value;
}

then in some other .cc file we introduce fake DictionaryValue class and use it:

class DictionaryValue {
 public:
  void* operator new (size_t) { return &instance_; }
  void operator delete(void*) {}

  void SetBoolean(const std::string& path, bool in_value) {}

  void SetString(const std::string& path, const std::string& in_value) {
    memory_size_ += sizeof(std::string) + in_value.capacity();
  }

  static size_t memory_size() { return memory_size_; }

 private:
  static size_t memory_size_;
  static DictionaryValue instance_;
};

#define USING_FAKE_VALUES
#include "proto_value_conversions.cc"

...

AppSettingsToValue(proto);
proto_memory_size = DictionaryValue::memory_size();


This is hacky, but at least the hackery is hidden. We can reduce changes further
(and make it even more hacky) by creating fake 'base' namespace and placing fake
DictionaryValue there. That avoids most changes to proto_value_conversions.cc.

https://codereview.chromium.org/2084243004/diff/170001/sync/syncable/director...
File sync/syncable/directory.cc (right):

https://codereview.chromium.org/2084243004/diff/170001/sync/syncable/director...
sync/syncable/directory.cc:50: size_t GetUnorderedMapMemoryUsage(const
std::unordered_map<Key, Value> map) {
I think you missed & here: const std::unordered_map<>& map.

https://codereview.chromium.org/2084243004/diff/170001/sync/syncable/director...
sync/syncable/directory.cc:957: for (auto entry :
kernel_->index_by_attachment_id)
const auto&, all other places too.

https://codereview.chromium.org/2084243004/diff/170001/sync/syncable/director...
sync/syncable/directory.cc:970: size_t entry_size = 0;
I think this whole thing should be moved into EntryKernel.

Powered by Google App Engine
This is Rietveld 408576698