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

Issue 1738063002: Refactor histogram_persistence to be a class. (Closed)

Created:
4 years, 10 months ago by bcwhite
Modified:
4 years, 9 months ago
CC:
chromium-reviews, grt+watch_chromium.org, wfh+watch_chromium.org, asvitkine+watch_chromium.org, vmpstr+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Refactor histogram_persistence to be a class. The number of top-level functions was getting too large and impeding development of other features due to the previous lack of OO design. The code is largely unchanged, just moved into a stateful class and reordered to match the public/private sections of the class. Two other CLs are included here because they fit well with the refactoring: https://codereview.chromium.org/1689833002/ Add ownership-transfer to histogram management calls. This CL changes the interface to use scoped_ptr to explicitly document, with std::move, when the transfer of ownership is taking place. https://codereview.chromium.org/1731453002/ Reduce histogram creation time by avoiding import of those just created. Attempting to import histograms in the persistent memory segment is necessary because it could be shared and thus have other processes creating objects within it. However, there's no need to import those objects that this process created. The simple method remembering the "reference" of the last histogram created in the allocator catches almost all cases and reduces histogram creation time by 40%. BUG=546019 TBR=grt,thakis grt: setup/installer_metrics.cc (no logic changes) thakis: gn & gyp changes for new files Committed: https://crrev.com/33d95806addac4c84a88eb8561ea424ef2097b6d Cr-Commit-Position: refs/heads/master@{#381386}

Patch Set 1 #

Patch Set 2 : removed unnecessary qualifiers in header file; some 'git cl format' changes #

Patch Set 3 : refactored (again) into PersistentHistogramAllocator class #

Total comments: 7

Patch Set 4 : addressed review comments by Alexi and temporarily re-order methods for easier review #

Total comments: 11

Patch Set 5 : addressed review comments by Alexei #

Patch Set 6 : create helper methods for creating global histogram allocators #

Total comments: 20

Patch Set 7 : addressed review comments by Alexei #

Patch Set 8 : move some parameters up a line #

Total comments: 8

Patch Set 9 : addressed review comments by Alexei #

Total comments: 13

Patch Set 10 : addressed final review comments by Alexei #

Unified diffs Side-by-side diffs Delta from patch set Stats (+711 lines, -1013 lines) Patch
M base/BUILD.gn View 1 2 2 chunks +3 lines, -2 lines 0 comments Download
M base/base.gyp View 1 2 1 chunk +1 line, -0 lines 0 comments Download
M base/base.gypi View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
M base/metrics/histogram.h View 1 2 6 chunks +41 lines, -37 lines 0 comments Download
M base/metrics/histogram.cc View 1 2 3 15 chunks +41 lines, -33 lines 0 comments Download
M base/metrics/histogram_persistence.h View 1 2 1 chunk +0 lines, -91 lines 0 comments Download
M base/metrics/histogram_persistence.cc View 1 2 1 chunk +0 lines, -516 lines 0 comments Download
M base/metrics/histogram_samples.h View 1 2 1 chunk +1 line, -1 line 0 comments Download
M base/metrics/histogram_unittest.cc View 1 2 3 4 5 6 chunks +14 lines, -103 lines 0 comments Download
A base/metrics/persistent_histogram_allocator.h View 1 2 3 4 5 6 7 8 9 1 chunk +212 lines, -0 lines 0 comments Download
A + base/metrics/persistent_histogram_allocator.cc View 1 2 3 4 5 6 7 8 9 14 chunks +226 lines, -188 lines 0 comments Download
A base/metrics/persistent_histogram_allocator_unittest.cc View 1 2 3 4 5 6 7 8 9 1 chunk +126 lines, -0 lines 0 comments Download
M base/metrics/statistics_recorder_unittest.cc View 1 2 3 4 5 4 chunks +5 lines, -5 lines 0 comments Download
M chrome/browser/chrome_browser_field_trials.cc View 1 2 3 4 5 2 chunks +6 lines, -6 lines 0 comments Download
M chrome/installer/setup/installer_metrics.cc View 1 2 3 4 5 1 chunk +10 lines, -10 lines 0 comments Download
M components/metrics/file_metrics_provider.cc View 1 2 4 chunks +12 lines, -10 lines 0 comments Download
M components/metrics/file_metrics_provider_unittest.cc View 1 2 3 4 5 3 chunks +8 lines, -6 lines 0 comments Download
M components/metrics/metrics_service.cc View 1 2 2 chunks +3 lines, -3 lines 0 comments Download

Messages

Total messages: 35 (15 generated)
bcwhite
https://codereview.chromium.org/1738063002/diff/80001/base/metrics/histogram.h File base/metrics/histogram.h (right): https://codereview.chromium.org/1738063002/diff/80001/base/metrics/histogram.h#newcode107 base/metrics/histogram.h:107: ~Histogram() override; This has to be made public (like ...
4 years, 9 months ago (2016-02-29 01:49:49 UTC) #5
bcwhite
4 years, 9 months ago (2016-02-29 01:51:11 UTC) #7
Alexei Svitkine (slow)
Any chance you could make this easier for me to review by keeping the same ...
4 years, 9 months ago (2016-03-03 18:11:28 UTC) #8
bcwhite
> Any chance you could make this easier for me to > review by keeping ...
4 years, 9 months ago (2016-03-04 21:17:16 UTC) #9
Alexei Svitkine (slow)
Wow, so much easier to review with the same order of methods. Looks great - ...
4 years, 9 months ago (2016-03-07 16:40:43 UTC) #10
bcwhite
https://codereview.chromium.org/1738063002/diff/100001/base/metrics/persistent_histogram_allocator.cc File base/metrics/persistent_histogram_allocator.cc (right): https://codereview.chromium.org/1738063002/diff/100001/base/metrics/persistent_histogram_allocator.cc#newcode252 base/metrics/persistent_histogram_allocator.cc:252: (histogram_data.bucket_count + 1) * sizeof(HistogramBase::Sample)) { On 2016/03/07 16:40:43, ...
4 years, 9 months ago (2016-03-08 00:24:04 UTC) #11
Alexei Svitkine (slow)
https://codereview.chromium.org/1738063002/diff/100001/chrome/browser/chrome_browser_field_trials.cc File chrome/browser/chrome_browser_field_trials.cc (right): https://codereview.chromium.org/1738063002/diff/100001/chrome/browser/chrome_browser_field_trials.cc#newcode38 chrome/browser/chrome_browser_field_trials.cc:38: make_scoped_ptr(new base::LocalPersistentMemoryAllocator( On 2016/03/08 00:24:04, bcwhite wrote: > On ...
4 years, 9 months ago (2016-03-08 19:58:29 UTC) #12
bcwhite
https://codereview.chromium.org/1738063002/diff/100001/chrome/browser/chrome_browser_field_trials.cc File chrome/browser/chrome_browser_field_trials.cc (right): https://codereview.chromium.org/1738063002/diff/100001/chrome/browser/chrome_browser_field_trials.cc#newcode38 chrome/browser/chrome_browser_field_trials.cc:38: make_scoped_ptr(new base::LocalPersistentMemoryAllocator( On 2016/03/08 19:58:28, Alexei Svitkine (slow) wrote: ...
4 years, 9 months ago (2016-03-09 04:01:51 UTC) #15
Alexei Svitkine (slow)
https://codereview.chromium.org/1738063002/diff/200001/base/metrics/histogram.cc File base/metrics/histogram.cc (right): https://codereview.chromium.org/1738063002/diff/200001/base/metrics/histogram.cc#newcode153 base/metrics/histogram.cc:153: // memory segment is not shared between processes, this ...
4 years, 9 months ago (2016-03-09 20:23:15 UTC) #17
bcwhite
https://codereview.chromium.org/1738063002/diff/200001/base/metrics/histogram.cc File base/metrics/histogram.cc (right): https://codereview.chromium.org/1738063002/diff/200001/base/metrics/histogram.cc#newcode153 base/metrics/histogram.cc:153: // memory segment is not shared between processes, this ...
4 years, 9 months ago (2016-03-09 21:14:59 UTC) #18
Alexei Svitkine (slow)
https://codereview.chromium.org/1738063002/diff/200001/base/metrics/histogram.cc File base/metrics/histogram.cc (right): https://codereview.chromium.org/1738063002/diff/200001/base/metrics/histogram.cc#newcode153 base/metrics/histogram.cc:153: // memory segment is not shared between processes, this ...
4 years, 9 months ago (2016-03-09 21:33:25 UTC) #19
bcwhite
https://codereview.chromium.org/1738063002/diff/200001/base/metrics/histogram.cc File base/metrics/histogram.cc (right): https://codereview.chromium.org/1738063002/diff/200001/base/metrics/histogram.cc#newcode153 base/metrics/histogram.cc:153: // memory segment is not shared between processes, this ...
4 years, 9 months ago (2016-03-10 00:45:26 UTC) #20
Alexei Svitkine (slow)
https://codereview.chromium.org/1738063002/diff/240001/base/metrics/persistent_histogram_allocator.h File base/metrics/persistent_histogram_allocator.h (right): https://codereview.chromium.org/1738063002/diff/240001/base/metrics/persistent_histogram_allocator.h#newcode51 base/metrics/persistent_histogram_allocator.h:51: size_t used() const { return memory_allocator_->used(); } Nit: Move ...
4 years, 9 months ago (2016-03-14 19:17:20 UTC) #21
bcwhite
https://codereview.chromium.org/1738063002/diff/240001/base/metrics/persistent_histogram_allocator.h File base/metrics/persistent_histogram_allocator.h (right): https://codereview.chromium.org/1738063002/diff/240001/base/metrics/persistent_histogram_allocator.h#newcode51 base/metrics/persistent_histogram_allocator.h:51: size_t used() const { return memory_allocator_->used(); } On 2016/03/14 ...
4 years, 9 months ago (2016-03-14 23:41:50 UTC) #22
Alexei Svitkine (slow)
lgtm https://codereview.chromium.org/1738063002/diff/260001/base/metrics/persistent_histogram_allocator.h File base/metrics/persistent_histogram_allocator.h (right): https://codereview.chromium.org/1738063002/diff/260001/base/metrics/persistent_histogram_allocator.h#newcode1 base/metrics/persistent_histogram_allocator.h:1: // Copyright (c) 2016 The Chromium Authors. All ...
4 years, 9 months ago (2016-03-15 22:00:10 UTC) #23
bcwhite
https://codereview.chromium.org/1738063002/diff/260001/base/metrics/persistent_histogram_allocator.h File base/metrics/persistent_histogram_allocator.h (right): https://codereview.chromium.org/1738063002/diff/260001/base/metrics/persistent_histogram_allocator.h#newcode1 base/metrics/persistent_histogram_allocator.h:1: // Copyright (c) 2016 The Chromium Authors. All rights ...
4 years, 9 months ago (2016-03-16 00:32:39 UTC) #25
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1738063002/320001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1738063002/320001
4 years, 9 months ago (2016-03-16 01:17:18 UTC) #30
commit-bot: I haz the power
Committed patchset #10 (id:320001)
4 years, 9 months ago (2016-03-16 02:37:54 UTC) #32
commit-bot: I haz the power
Patchset 10 (id:??) landed as https://crrev.com/33d95806addac4c84a88eb8561ea424ef2097b6d Cr-Commit-Position: refs/heads/master@{#381386}
4 years, 9 months ago (2016-03-16 02:38:56 UTC) #34
Alexei Svitkine (slow)
4 years, 9 months ago (2016-03-16 15:14:08 UTC) #35
Message was sent while issue was closed.
https://codereview.chromium.org/1738063002/diff/260001/base/metrics/persisten...
File base/metrics/persistent_histogram_allocator_unittest.cc (right):

https://codereview.chromium.org/1738063002/diff/260001/base/metrics/persisten...
base/metrics/persistent_histogram_allocator_unittest.cc:23: void TearDown()
override { DestroyPersistentHistogramAllocator(); }
On 2016/03/16 00:32:39, bcwhite wrote:
> On 2016/03/15 22:00:10, Alexei Svitkine (very slow) wrote:
> > Instead of needing to override SetUp() or TearDown(), you can just make the
> two
> > calls in the constructor/dtor. Even if there are multiple test cases, the
> > ctor/dtor will still be run once. each.
> 
> Done.  Though what's the point of setup/teardown, then, if they're pretty much
> the same as the ctor/dtor?

Don't know - I agree they seem superfulous.

Powered by Google App Engine
This is Rietveld 408576698