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

Issue 804942 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Dec 1
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 2
Type: Feature



Sign in to add a comment

Sampling profiler: optimize in-memory stack representation

Project Member Reported by wittman@chromium.org, Jan 23 2018

Issue description

Currently the profiler stores all of the collected stacks individually in memory. At 300 stacks, ~22 frames/stack, 16 bytes/frame, this works out to 106k for each collection for each thread, plus module information and overhead.

In the typical case most of the stacks are idling in the message loop and so are the same. We can substantially reduce the memory usage by only storing one stack for all of these rather than multiple.

Proposed approach: store distinct stacks rather than individual stacks in StackSamplingProfiler::CallStackProfile. Add a vector of struct { size_t index, uint32_t process_milestones } to record each sample's stack index, plus process milestones.
 

Comment 1 by chengx@chromium.org, Jan 23 2018

Cc: brucedaw...@chromium.org
Owner: chengx@chromium.org
Status: Assigned (was: Available)
I will take it.

Comment 2 by chengx@chromium.org, Jan 31 2018

Owner: ----
Status: Available (was: Assigned)
I don't have time for this now, so release the ownership.
Cc: -chengx@chromium.org
Owner: chengx@chromium.org
Status: Assigned (was: Available)
Project Member

Comment 4 by bugdroid1@chromium.org, Aug 10

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/4dec7e4be7cd60095129ccc0fc9667112817d604

commit 4dec7e4be7cd60095129ccc0fc9667112817d604
Author: Xi Cheng <chengx@chromium.org>
Date: Fri Aug 10 16:54:11 2018

Directly write SampledProfile protocol buffer message and send over mojo

This change removes the current execution profile _mojo_ representation
in favor of directly writing the data in the protocol buffer format used
for UMA upload. The reasons for using this format are:
1. it's the format that we ultimately need the data in;
2. it's the most memory-efficient representation available to us, because
   of the protocol buffer varint encoding;
3. the serialized protocol buffers are trivially compressible.

We generate execution profiles in non-browser processes, so this means
writing the protocol buffer representation in those processes and sending
over mojo to the browser process, where the UMA upload takes place.

We're making this change as part of a refactoring to expand the profiling
scenarios supported by the UMA Sampling Profiler. A key aspect of this
refactoring is reducing memory consumption of the execution profile
representation. See http://crbug.com/850148 for examples of memory usage
problems with this representation.

Bug: 851163,  804942 
Change-Id: Ied88d6fd932587707c1f5a4c79acd77d5911f6ee
Reviewed-on: https://chromium-review.googlesource.com/1157547
Commit-Queue: Mike Wittman <wittman@chromium.org>
Reviewed-by: Steven Holte <holte@chromium.org>
Reviewed-by: Mike Wittman <wittman@chromium.org>
Reviewed-by: François Doray <fdoray@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582209}
[modify] https://crrev.com/4dec7e4be7cd60095129ccc0fc9667112817d604/chrome/browser/chrome_browser_main.cc
[modify] https://crrev.com/4dec7e4be7cd60095129ccc0fc9667112817d604/chrome/common/DEPS
[modify] https://crrev.com/4dec7e4be7cd60095129ccc0fc9667112817d604/chrome/common/thread_profiler.cc
[modify] https://crrev.com/4dec7e4be7cd60095129ccc0fc9667112817d604/chrome/common/thread_profiler.h
[modify] https://crrev.com/4dec7e4be7cd60095129ccc0fc9667112817d604/components/metrics/BUILD.gn
[modify] https://crrev.com/4dec7e4be7cd60095129ccc0fc9667112817d604/components/metrics/call_stack_profile_builder.cc
[modify] https://crrev.com/4dec7e4be7cd60095129ccc0fc9667112817d604/components/metrics/call_stack_profile_builder.h
[modify] https://crrev.com/4dec7e4be7cd60095129ccc0fc9667112817d604/components/metrics/call_stack_profile_builder_unittest.cc
[modify] https://crrev.com/4dec7e4be7cd60095129ccc0fc9667112817d604/components/metrics/call_stack_profile_collector.cc
[modify] https://crrev.com/4dec7e4be7cd60095129ccc0fc9667112817d604/components/metrics/call_stack_profile_collector.h
[modify] https://crrev.com/4dec7e4be7cd60095129ccc0fc9667112817d604/components/metrics/call_stack_profile_metrics_provider.cc
[modify] https://crrev.com/4dec7e4be7cd60095129ccc0fc9667112817d604/components/metrics/call_stack_profile_metrics_provider.h
[modify] https://crrev.com/4dec7e4be7cd60095129ccc0fc9667112817d604/components/metrics/call_stack_profile_metrics_provider_unittest.cc
[add] https://crrev.com/4dec7e4be7cd60095129ccc0fc9667112817d604/components/metrics/call_stack_profile_proto_encoder.cc
[add] https://crrev.com/4dec7e4be7cd60095129ccc0fc9667112817d604/components/metrics/call_stack_profile_proto_encoder.h
[add] https://crrev.com/4dec7e4be7cd60095129ccc0fc9667112817d604/components/metrics/call_stack_profile_proto_encoder_unittest.cc
[modify] https://crrev.com/4dec7e4be7cd60095129ccc0fc9667112817d604/components/metrics/child_call_stack_profile_collector.cc
[modify] https://crrev.com/4dec7e4be7cd60095129ccc0fc9667112817d604/components/metrics/child_call_stack_profile_collector.h
[modify] https://crrev.com/4dec7e4be7cd60095129ccc0fc9667112817d604/components/metrics/child_call_stack_profile_collector_unittest.cc
[modify] https://crrev.com/4dec7e4be7cd60095129ccc0fc9667112817d604/components/metrics/public/cpp/BUILD.gn
[modify] https://crrev.com/4dec7e4be7cd60095129ccc0fc9667112817d604/components/metrics/public/cpp/call_stack_profile.typemap
[modify] https://crrev.com/4dec7e4be7cd60095129ccc0fc9667112817d604/components/metrics/public/cpp/call_stack_profile_struct_traits.h
[modify] https://crrev.com/4dec7e4be7cd60095129ccc0fc9667112817d604/components/metrics/public/cpp/call_stack_profile_struct_traits_unittest.cc
[add] https://crrev.com/4dec7e4be7cd60095129ccc0fc9667112817d604/components/metrics/public/cpp/call_stack_profile_unittest.typemap
[modify] https://crrev.com/4dec7e4be7cd60095129ccc0fc9667112817d604/components/metrics/public/cpp/typemaps.gni
[modify] https://crrev.com/4dec7e4be7cd60095129ccc0fc9667112817d604/components/metrics/public/interfaces/call_stack_profile_collector.mojom
[modify] https://crrev.com/4dec7e4be7cd60095129ccc0fc9667112817d604/components/metrics/public/interfaces/call_stack_profile_collector_test.mojom
[modify] https://crrev.com/4dec7e4be7cd60095129ccc0fc9667112817d604/components/startup_metric_utils/browser/startup_metric_utils.cc

Project Member

Comment 5 by bugdroid1@chromium.org, Aug 14

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/e91f6fdb3d1b31b3c9ca8370fcab83a290118358

commit e91f6fdb3d1b31b3c9ca8370fcab83a290118358
Author: Xi Cheng <chengx@chromium.org>
Date: Tue Aug 14 16:34:56 2018

Build SampledProfile protocol buffer message incrementally

This completes the task to remove the current memory-inefficient execution
profile representation by StackSamplingProfiler::CallStackProfile.

This change also leads to the following structural changes:
1) The intermediate representation of a call stack profile --
   StackSamplingProfiler::CallStackProfile is retired.
2) Module/Frame/Sample structs are moved from the StackSamplingProfiler
   class to the CallStackProfileBuilder class as now they are only used by
   the latter one.
3) Methods in call_stack_profile_proto_encoder.h are moved to
   stack_sampling_profiler.cc as now they are only used there.

Bug: 851163,  804942 
Change-Id: Ief07693499a2eb9af216d0ec71b9daf38645ecba
Reviewed-on: https://chromium-review.googlesource.com/1171866
Reviewed-by: Mike Wittman <wittman@chromium.org>
Reviewed-by: Ilya Sherman <isherman@chromium.org>
Commit-Queue: Xi Cheng <chengx@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582937}
[modify] https://crrev.com/e91f6fdb3d1b31b3c9ca8370fcab83a290118358/base/profiler/native_stack_sampler.h
[modify] https://crrev.com/e91f6fdb3d1b31b3c9ca8370fcab83a290118358/base/profiler/native_stack_sampler_mac.cc
[modify] https://crrev.com/e91f6fdb3d1b31b3c9ca8370fcab83a290118358/base/profiler/native_stack_sampler_win.cc
[modify] https://crrev.com/e91f6fdb3d1b31b3c9ca8370fcab83a290118358/base/profiler/stack_sampling_profiler.cc
[modify] https://crrev.com/e91f6fdb3d1b31b3c9ca8370fcab83a290118358/base/profiler/stack_sampling_profiler.h
[modify] https://crrev.com/e91f6fdb3d1b31b3c9ca8370fcab83a290118358/base/profiler/stack_sampling_profiler_unittest.cc
[modify] https://crrev.com/e91f6fdb3d1b31b3c9ca8370fcab83a290118358/chrome/common/thread_profiler.cc
[modify] https://crrev.com/e91f6fdb3d1b31b3c9ca8370fcab83a290118358/components/metrics/BUILD.gn
[modify] https://crrev.com/e91f6fdb3d1b31b3c9ca8370fcab83a290118358/components/metrics/call_stack_profile_builder.cc
[modify] https://crrev.com/e91f6fdb3d1b31b3c9ca8370fcab83a290118358/components/metrics/call_stack_profile_builder.h
[modify] https://crrev.com/e91f6fdb3d1b31b3c9ca8370fcab83a290118358/components/metrics/call_stack_profile_builder_unittest.cc
[modify] https://crrev.com/e91f6fdb3d1b31b3c9ca8370fcab83a290118358/components/metrics/call_stack_profile_collector.cc
[delete] https://crrev.com/97b24d6f3f4872591db9457559a7fc6bde01aaa2/components/metrics/call_stack_profile_proto_encoder.cc
[delete] https://crrev.com/97b24d6f3f4872591db9457559a7fc6bde01aaa2/components/metrics/call_stack_profile_proto_encoder.h
[delete] https://crrev.com/97b24d6f3f4872591db9457559a7fc6bde01aaa2/components/metrics/call_stack_profile_proto_encoder_unittest.cc

Project Member

Comment 6 by bugdroid1@chromium.org, Aug 15

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/eb46484d16902f6ed17824eb4ef299d262fe6bd0

commit eb46484d16902f6ed17824eb4ef299d262fe6bd0
Author: Xi Cheng <chengx@chromium.org>
Date: Wed Aug 15 01:00:28 2018

Replace CallStackProfileBuilder::Module with ModuleCache::Module

Bug: 851163,  804942 
Change-Id: I4da05d9c4e3a4c12f8b3c851d074fa3cdf97679f
Reviewed-on: https://chromium-review.googlesource.com/1174953
Commit-Queue: Xi Cheng <chengx@chromium.org>
Reviewed-by: Mike Wittman <wittman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583111}
[modify] https://crrev.com/eb46484d16902f6ed17824eb4ef299d262fe6bd0/components/metrics/call_stack_profile_builder.cc
[modify] https://crrev.com/eb46484d16902f6ed17824eb4ef299d262fe6bd0/components/metrics/call_stack_profile_builder.h

Project Member

Comment 7 by bugdroid1@chromium.org, Aug 31

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/2943c9c7082865f62153731e4d34414a286e6f4b

commit 2943c9c7082865f62153731e4d34414a286e6f4b
Author: Mike Wittman <wittman@chromium.org>
Date: Fri Aug 31 19:28:57 2018

Reland "Rationalize call stacks targets in //components/metrics/BUILD.gn"

Relanding with fix for ChromeContentRendererClientMetricsTest.

Renames targets to better reflect what they provide. Removes the
:metrics dep from the target for child processes to avoid including
unnecessary browser-process-only code in those processes. Breaks the
direct dependency of CallStackProfileBuilder on :metrics by introducing
a receiver callback abstraction.

TBR=sky

Bug:  878509 ,  879513 ,  804942 
Change-Id: Ib83ad55a31b98022531a8dad740c7d5516db8caf
Reviewed-on: https://chromium-review.googlesource.com/1199764
Reviewed-by: Mike Wittman <wittman@chromium.org>
Commit-Queue: Mike Wittman <wittman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#588114}
[modify] https://crrev.com/2943c9c7082865f62153731e4d34414a286e6f4b/chrome/browser/BUILD.gn
[modify] https://crrev.com/2943c9c7082865f62153731e4d34414a286e6f4b/chrome/browser/chrome_browser_main.cc
[modify] https://crrev.com/2943c9c7082865f62153731e4d34414a286e6f4b/chrome/common/BUILD.gn
[modify] https://crrev.com/2943c9c7082865f62153731e4d34414a286e6f4b/chrome/common/thread_profiler.cc
[modify] https://crrev.com/2943c9c7082865f62153731e4d34414a286e6f4b/chrome/common/thread_profiler.h
[modify] https://crrev.com/2943c9c7082865f62153731e4d34414a286e6f4b/chrome/gpu/BUILD.gn
[modify] https://crrev.com/2943c9c7082865f62153731e4d34414a286e6f4b/chrome/renderer/chrome_content_renderer_client_unittest.cc
[modify] https://crrev.com/2943c9c7082865f62153731e4d34414a286e6f4b/components/metrics/BUILD.gn
[modify] https://crrev.com/2943c9c7082865f62153731e4d34414a286e6f4b/components/metrics/call_stack_profile_builder.cc
[modify] https://crrev.com/2943c9c7082865f62153731e4d34414a286e6f4b/components/metrics/call_stack_profile_builder.h
[modify] https://crrev.com/2943c9c7082865f62153731e4d34414a286e6f4b/components/startup_metric_utils/browser/BUILD.gn

Project Member

Comment 8 by bugdroid1@chromium.org, Sep 5

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/16fa536a2e0e88205dceb6c0c078784affa44cc9

commit 16fa536a2e0e88205dceb6c0c078784affa44cc9
Author: Mike Wittman <wittman@chromium.org>
Date: Tue Sep 04 17:27:30 2018

[Sampling profiler] Store child call stack profiles in serialized form

Delays the proto deserialization of call stack profiles from mojo
receive time to metrics log upload time. This significantly reduces
memory requirements for storing the profiles since the serialized form
has a much smaller representation.

Bug: 875938,  804942 
Change-Id: Idfb24c5cb06e167918fd56ee4d92e3f598e7af39
Reviewed-on: https://chromium-review.googlesource.com/1199941
Reviewed-by: Ilya Sherman <isherman@chromium.org>
Reviewed-by: Scott Violet <sky@chromium.org>
Commit-Queue: Mike Wittman <wittman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#588568}
[modify] https://crrev.com/16fa536a2e0e88205dceb6c0c078784affa44cc9/chrome/browser/chrome_browser_main.cc
[modify] https://crrev.com/16fa536a2e0e88205dceb6c0c078784affa44cc9/chrome/browser/chrome_content_browser_client.cc
[modify] https://crrev.com/16fa536a2e0e88205dceb6c0c078784affa44cc9/components/metrics/BUILD.gn
[modify] https://crrev.com/16fa536a2e0e88205dceb6c0c078784affa44cc9/components/metrics/call_stack_profile_collector.cc
[modify] https://crrev.com/16fa536a2e0e88205dceb6c0c078784affa44cc9/components/metrics/call_stack_profile_collector.h
[modify] https://crrev.com/16fa536a2e0e88205dceb6c0c078784affa44cc9/components/metrics/call_stack_profile_metrics_provider.cc
[modify] https://crrev.com/16fa536a2e0e88205dceb6c0c078784affa44cc9/components/metrics/call_stack_profile_metrics_provider.h
[modify] https://crrev.com/16fa536a2e0e88205dceb6c0c078784affa44cc9/components/metrics/call_stack_profile_metrics_provider_unittest.cc
[modify] https://crrev.com/16fa536a2e0e88205dceb6c0c078784affa44cc9/components/metrics/child_call_stack_profile_collector.cc
[modify] https://crrev.com/16fa536a2e0e88205dceb6c0c078784affa44cc9/components/metrics/child_call_stack_profile_collector_unittest.cc
[delete] https://crrev.com/d5db3d9b1b63b30fbeb16706b86513b1f2859937/components/metrics/public/cpp/BUILD.gn
[delete] https://crrev.com/d5db3d9b1b63b30fbeb16706b86513b1f2859937/components/metrics/public/cpp/OWNERS
[delete] https://crrev.com/d5db3d9b1b63b30fbeb16706b86513b1f2859937/components/metrics/public/cpp/call_stack_profile.typemap
[delete] https://crrev.com/d5db3d9b1b63b30fbeb16706b86513b1f2859937/components/metrics/public/cpp/call_stack_profile_struct_traits.h
[delete] https://crrev.com/d5db3d9b1b63b30fbeb16706b86513b1f2859937/components/metrics/public/cpp/call_stack_profile_struct_traits_unittest.cc
[delete] https://crrev.com/d5db3d9b1b63b30fbeb16706b86513b1f2859937/components/metrics/public/cpp/call_stack_profile_unittest.typemap
[delete] https://crrev.com/d5db3d9b1b63b30fbeb16706b86513b1f2859937/components/metrics/public/cpp/typemaps.gni
[modify] https://crrev.com/16fa536a2e0e88205dceb6c0c078784affa44cc9/mojo/public/tools/bindings/chromium_bindings_configuration.gni

Project Member

Comment 9 by bugdroid1@chromium.org, Sep 11

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/b2e858e59f4f4a055669adf99b5e94983ba69850

commit b2e858e59f4f4a055669adf99b5e94983ba69850
Author: Xi Cheng <chengx@chromium.org>
Date: Tue Sep 11 20:58:03 2018

Introduce new CallStackProfileBuilder using the new StackSample encoding

We deliberately leave out the process phase metadata information in the
StackSample encoding in this CL. Implementing that metadata support will
need to be done differently to make it extensible to general metadata.
We will implement it using follow-up CLs.

The old CallStackProfileBuilder using the legacy Sample encoding is
renamed to LegacyCallStackProfileBuilder. Related files are renamed
accordingly too.

Note that the old CallStackProfileBuilder is still used in production.

Bug: 851163,  804942 
Change-Id: I235bd8cc839de4e663f1d4bd49aa24485649692a
Reviewed-on: https://chromium-review.googlesource.com/1205896
Reviewed-by: François Doray <fdoray@chromium.org>
Reviewed-by: Ilya Sherman <isherman@chromium.org>
Reviewed-by: Siddhartha S <ssid@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Alexei Filippov <alph@chromium.org>
Reviewed-by: Mike Wittman <wittman@chromium.org>
Commit-Queue: Xi Cheng <chengx@chromium.org>
Cr-Commit-Position: refs/heads/master@{#590465}
[modify] https://crrev.com/b2e858e59f4f4a055669adf99b5e94983ba69850/base/profiler/stack_sampling_profiler.cc
[modify] https://crrev.com/b2e858e59f4f4a055669adf99b5e94983ba69850/base/profiler/stack_sampling_profiler.h
[modify] https://crrev.com/b2e858e59f4f4a055669adf99b5e94983ba69850/chrome/browser/chrome_browser_main.cc
[modify] https://crrev.com/b2e858e59f4f4a055669adf99b5e94983ba69850/chrome/common/DEPS
[modify] https://crrev.com/b2e858e59f4f4a055669adf99b5e94983ba69850/chrome/common/heap_profiler_controller.cc
[modify] https://crrev.com/b2e858e59f4f4a055669adf99b5e94983ba69850/chrome/common/heap_profiler_controller_unittest.cc
[modify] https://crrev.com/b2e858e59f4f4a055669adf99b5e94983ba69850/chrome/common/thread_profiler.cc
[modify] https://crrev.com/b2e858e59f4f4a055669adf99b5e94983ba69850/chrome/common/thread_profiler.h
[modify] https://crrev.com/b2e858e59f4f4a055669adf99b5e94983ba69850/components/metrics/BUILD.gn
[modify] https://crrev.com/b2e858e59f4f4a055669adf99b5e94983ba69850/components/metrics/call_stack_profile_builder.cc
[modify] https://crrev.com/b2e858e59f4f4a055669adf99b5e94983ba69850/components/metrics/call_stack_profile_builder.h
[modify] https://crrev.com/b2e858e59f4f4a055669adf99b5e94983ba69850/components/metrics/call_stack_profile_builder_unittest.cc
[add] https://crrev.com/b2e858e59f4f4a055669adf99b5e94983ba69850/components/metrics/legacy_call_stack_profile_builder.cc
[add] https://crrev.com/b2e858e59f4f4a055669adf99b5e94983ba69850/components/metrics/legacy_call_stack_profile_builder.h
[add] https://crrev.com/b2e858e59f4f4a055669adf99b5e94983ba69850/components/metrics/legacy_call_stack_profile_builder_unittest.cc
[modify] https://crrev.com/b2e858e59f4f4a055669adf99b5e94983ba69850/components/startup_metric_utils/browser/startup_metric_utils.cc
[modify] https://crrev.com/b2e858e59f4f4a055669adf99b5e94983ba69850/components/tracing/common/tracing_sampler_profiler.cc

Cc: -wittman@chromium.org chengx@chromium.org
Owner: wittman@chromium.org
Status: Fixed (was: Assigned)
This was fixed in 256700143f56fd96c97185bd63f9c9b71625ae40.

Sign in to add a comment