|
|
Created:
4 years, 1 month ago by Primiano Tucci (use gerrit) Modified:
4 years, 1 month ago CC:
chromium-reviews, tracing+reviews_chromium.org, wfh+watch_chromium.org, fmeawad, caseq, alph Target Ref:
refs/pending/heads/master Project:
chromium Visibility:
Public. |
Descriptiontracing: split out the CategoryRegistry from the TraceLog
Changes introduced by this CL:
- Split out the category logic out of the TraceLog into CategoryRegistry.
Makes it easier to unbundle, reuse and reason about.
- Get rid of the parallel arrays for tracking names, filters and state
of each category and switch them to one array of struct. This not
only makes the code easier to read, but also opens the way for
having categories defined at compile time that don't need any
lazy initialization of the "enabled" ptr.
- Naming cleanup: the term "category group" has always been confusing.
All it does is reflecting a subtle implementation detail (the fact
that a category name can be "cat1,cat2") which is quite irrelevant
from a functional viewpoint.
BUG=659689
Committed: https://crrev.com/094ac7f87d78a80e3934e148855a908977559166
Cr-Commit-Position: refs/heads/master@{#431300}
Patch Set 1 : fix test checks #
Total comments: 10
Patch Set 2 : Add constexpr to avoid static initializer and address initial comments #Patch Set 3 : Workaround clang bug crbug.com/660828 #Patch Set 4 : Don't outsmart compilers. They win by playing the plausible deniability card of undefined behavior. #Patch Set 5 : Add is_pod check #Patch Set 6 : add tests, rebase #
Messages
Total messages: 81 (63 generated)
The CQ bit was checked by primiano@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: chromium_presubmit on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromium_presub...)
The CQ bit was checked by primiano@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: chromium_presubmit on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromium_presub...)
The CQ bit was checked by primiano@chromium.org to run a CQ dry run
Patchset #2 (id:20001) has been deleted
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Description was changed from ========== WIP category BUG= ========== to ========== tracing: split out the CategoryRegistry from the TraceLog This is a refactoring in light of the upcoming tracing reorg/unbundling. This CL splits out the category logic out of the TraceLog and allows it to be more easily reused. Furthermore this CL takes the occasion for some naming cleanup: "category group" has always been a confusing name and all it does is reflecting a mere and subtle implementation detail (the fact that a category name can be "cat1,cat2") which is quite irrelevant from a functional viewpoint. BUG=659689 ==========
Description was changed from ========== tracing: split out the CategoryRegistry from the TraceLog This is a refactoring in light of the upcoming tracing reorg/unbundling. This CL splits out the category logic out of the TraceLog and allows it to be more easily reused. Furthermore this CL takes the occasion for some naming cleanup: "category group" has always been a confusing name and all it does is reflecting a mere and subtle implementation detail (the fact that a category name can be "cat1,cat2") which is quite irrelevant from a functional viewpoint. BUG=659689 ========== to ========== tracing: split out the CategoryRegistry from the TraceLog Changes introduced by this CL: - Split out the category logic out of the TraceLog into CategoryRegistry. Makes it easier to unbundle, reuse and reason about. - Get rid of the parallel arrays for tracking names, filters and state of each category and switch them to one array of struct. This not only makes the code easier to read, but also opens the way for having categories defined at compile time that don't need any lazy initialization of the "enabled" ptr. - Naming cleanup: the term "category group" has always been confusing. All it does is reflecting a subtle implementation detail (the fact that a category name can be "cat1,cat2") which is quite irrelevant from a functional viewpoint. BUG=659689 ==========
The CQ bit was checked by primiano@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
primiano@chromium.org changed reviewers: + oysteine@chromium.org
allright, let's start some autumn cleanup. Looks like doing the non-categories might be easier than expected.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: ios-simulator on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-simulator/bui...)
The CQ bit was checked by primiano@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
fmeawad@chromium.org changed reviewers: + fmeawad@chromium.org
Concerning the naming cleanup, I don't think that category group is confusing. In my opinion: cat1,cat2 is a group of 2 categories cat1 and cat2. I think calling cat1,cat2 a category may result in later confusion when we are refactoring the traceconfig subsystem Otherwise, super excited for this refactor.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: ios-simulator on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/ios-simulator/bui...)
The CQ bit was checked by primiano@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: mac_chromium_rel_ng on master.tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_...)
On 2016/10/26 17:36:00, fmeawad wrote: > Concerning the naming cleanup, I don't think that category group is confusing. > In my opinion: cat1,cat2 is a group of 2 categories cat1 and cat2. I think > calling cat1,cat2 a category may result in later confusion when we are > refactoring the traceconfig subsystem > > Otherwise, super excited for this refactor. I'm a little bit conflicted about this. To some degree, on the tracelog level there's really just "category string" with no knowledge of what's actually in that string and how it's used. The knowledge that there's such a thing as comma-separated categories and you can tell the config you just need to match one of them, is strictly defined by the TraceConfig. It's opaque to the other parts of the system, and if the end result of all of this is that TraceConfig becomes an impl-level thing and could differ between implementations that may matter. But I don't think it's right to call it "category" either. "CategoryConfig"?
partial first pass https://codereview.chromium.org/2452063003/diff/120001/base/trace_event/categ... File base/trace_event/category_registry.cc (right): https://codereview.chromium.org/2452063003/diff/120001/base/trace_event/categ... base/trace_event/category_registry.cc:34: base::LazyInstance<base::Lock>::Leaky g_category_lock = Lazily created locks scare me :). Are we sure there's no races for the lock creation itself? https://codereview.chromium.org/2452063003/diff/120001/base/trace_event/categ... base/trace_event/category_registry.cc:37: void DCheckIsValidCategoryPtr(const TraceCategory* category) { #if DCHECK_IS_ON() rather than "DCheck" as part of the name, both around the definition and the callsites, might be clearer (and more verbose, I realize, but I think that's the pattern generally in use). https://codereview.chromium.org/2452063003/diff/120001/base/trace_event/categ... base/trace_event/category_registry.cc:48: TraceCategory* const CategoryRegistry::kCategoryExhausted = &g_categories[0]; Why are these outside of the anonymous namespace? https://codereview.chromium.org/2452063003/diff/120001/base/trace_event/categ... base/trace_event/category_registry.cc:146: return p < reinterpret_cast<uintptr_t>(&g_categories[kNumBuiltinCategories]); Hmm do we actually need all o the uintptr_t casting? I thought pointers to within the same array could be compared directly. https://codereview.chromium.org/2452063003/diff/120001/base/trace_event/categ... File base/trace_event/category_registry.h (right): https://codereview.chromium.org/2452063003/diff/120001/base/trace_event/categ... base/trace_event/category_registry.h:29: : begin_(begin), end_(end) {} Can we DCHECK(begin_ <= end_)?
On 2016/10/28 00:40:19, oystein wrote: > On 2016/10/26 17:36:00, fmeawad wrote: > > Concerning the naming cleanup, I don't think that category group is confusing. > > In my opinion: cat1,cat2 is a group of 2 categories cat1 and cat2. I think > > calling cat1,cat2 a category may result in later confusion when we are > > refactoring the traceconfig subsystem > > > > Otherwise, super excited for this refactor. > > I'm a little bit conflicted about this. To some degree, on the tracelog level > there's really just "category string" with no knowledge of what's actually in > that string and how it's used. The knowledge that there's such a thing as > comma-separated categories and you can tell the config you just need to match > one of them, is strictly defined by the TraceConfig. It's opaque to the other > parts of the system, and if the end result of all of this is that TraceConfig > becomes an impl-level thing and could differ between implementations that may > matter. But I don't think it's right to call it "category" either. > "CategoryConfig"? I agree with Oystein here. The "comma" behavior is totally a feature of the TraceConfig not the rest of the trace machinery. Nothing here cares about commas. From a more practical view, the usage of category "groups" is ~6% (71 vs 1057, see [1,2]) so I'd say it's a pretty unusual feature. Happy to find a different name which is not just "Category". CategoryConfig though smells too close to TraceConfig. Any other proposal? [1] https://cs.chromium.org/search/?q=TRACE_EVENT%5Cw%2B%5C(%5C%22%5B%5E%22%5D%2B... [2] https://cs.chromium.org/search/?q=TRACE_EVENT%5Cw%2B%5C(%5C%22&sq=package:chr... https://codereview.chromium.org/2452063003/diff/120001/base/trace_event/categ... File base/trace_event/category_registry.cc (right): https://codereview.chromium.org/2452063003/diff/120001/base/trace_event/categ... base/trace_event/category_registry.cc:34: base::LazyInstance<base::Lock>::Leaky g_category_lock = On 2016/10/28 06:28:00, oystein wrote: > Lazily created locks scare me :). Are we sure there's no races for the lock > creation itself? This is a quite established pattern: https://cs.chromium.org/search/?q=LazyInstance%3Cbase::Lock%3E&sq=package:chr... The problem is the following: in theory I'd want just a base::Lock here. I can't just do that because that would cause a static initializer. So I wrap it in a LazyInstance. LazyInstance itself has the right barriers to gurantee threadsafe initialization. See comment in base/lazy_instance.h Having said that, I was thinking to rip out this lock at some point before the unbundling and just use a spinlock with atomics. I don't want to have to port LazyInstance in whatever_will_be/core and the critical section here is really trivial, as we don't do any initialization, just a bunch of strcmp. https://codereview.chromium.org/2452063003/diff/120001/base/trace_event/categ... base/trace_event/category_registry.cc:37: void DCheckIsValidCategoryPtr(const TraceCategory* category) { On 2016/10/28 06:28:00, oystein wrote: > #if DCHECK_IS_ON() rather than "DCheck" as part of the name, both around the > definition and the callsites, might be clearer (and more verbose, I realize, but > I think that's the pattern generally in use). Actually thinking more I think the right pattern is: - this function just being a "bool IsValidCategory". - use DCHECK(IsValidCategory(...)) makes both sense from a readability viewpoint and also is the pattern used by DCHECK(thread_checker_.CalledOnValidThread()); https://codereview.chromium.org/2452063003/diff/120001/base/trace_event/categ... base/trace_event/category_registry.cc:48: TraceCategory* const CategoryRegistry::kCategoryExhausted = &g_categories[0]; On 2016/10/28 06:28:00, oystein wrote: > Why are these outside of the anonymous namespace? because I want to be able to reference to some of these in the code. For instance kCategoryMetadata is referenced by trace_log.cc This is the way we will get rid of the deferred static category_group_enabled f checks. Now you can just have the compiler initialize the category_group_enabled in the macros by just using these objects.I just need to change the macros from caching the ptr to the word, to the ptr of the full TraceCategory object (which is really the same pointer, because I guarantee that the enabled flag is the first field of the TraceCategory). Will do in some next CLs. In theory I could move kCategoryExhausted and kCategoryAlreadyShutdown to anon namespace and leave kMetadata here. But IMHO it feels more readable if they are all in the same place one after the other. https://codereview.chromium.org/2452063003/diff/120001/base/trace_event/categ... base/trace_event/category_registry.cc:146: return p < reinterpret_cast<uintptr_t>(&g_categories[kNumBuiltinCategories]); On 2016/10/28 06:28:00, oystein wrote: > Hmm do we actually need all o the uintptr_t casting? I thought pointers to > within the same array could be compared directly. good point. you are right. done. https://codereview.chromium.org/2452063003/diff/120001/base/trace_event/categ... File base/trace_event/category_registry.h (right): https://codereview.chromium.org/2452063003/diff/120001/base/trace_event/categ... base/trace_event/category_registry.h:29: : begin_(begin), end_(end) {} On 2016/10/28 06:28:00, oystein wrote: > Can we DCHECK(begin_ <= end_)? Done.
The CQ bit was checked by primiano@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: linux_chromium_chromeos_rel_ng on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
The CQ bit was checked by primiano@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: chromium_presubmit on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromium_presub...)
Patchset #8 (id:160001) has been deleted
The CQ bit was checked by primiano@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: Try jobs failed on following builders: chromium_presubmit on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromium_presub...)
Patchset #5 (id:100001) has been deleted
Patchset #4 (id:80001) has been deleted
The CQ bit was checked by primiano@chromium.org to run a CQ dry run
Patchset #1 (id:1) has been deleted
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Patchset #1 (id:40001) has been deleted
Patchset #1 (id:60001) has been deleted
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
The CQ bit was checked by primiano@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
Ok this seems ready to go % name of TraceCategory if anybody wants to come up with something else. Fun times with compilers (https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/688aPLsA5jU)
Was the old code tested and we are reusing the tests? are we relying on some end to end testing, or is it worth it adding tests here?
The CQ bit was checked by primiano@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
On 2016/11/01 20:48:32, fmeawad wrote: > Was the old code tested and we are reusing the tests? are we relying on some end > to end testing, or is it worth it adding tests here? Yup this code is still covered by the old tests. However extra tests are never bad, so I just added new ones in the latest patchset.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
ping.
Thanks, lgtm
The CQ bit was checked by primiano@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: chromium_presubmit on master.tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/chromium_presub...)
primiano@chromium.org changed reviewers: + thakis@chromium.org
ehm, +thakis for base/BUILD.gn stamp
lgtm
The CQ bit was checked by primiano@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Message was sent while issue was closed.
Description was changed from ========== tracing: split out the CategoryRegistry from the TraceLog Changes introduced by this CL: - Split out the category logic out of the TraceLog into CategoryRegistry. Makes it easier to unbundle, reuse and reason about. - Get rid of the parallel arrays for tracking names, filters and state of each category and switch them to one array of struct. This not only makes the code easier to read, but also opens the way for having categories defined at compile time that don't need any lazy initialization of the "enabled" ptr. - Naming cleanup: the term "category group" has always been confusing. All it does is reflecting a subtle implementation detail (the fact that a category name can be "cat1,cat2") which is quite irrelevant from a functional viewpoint. BUG=659689 ========== to ========== tracing: split out the CategoryRegistry from the TraceLog Changes introduced by this CL: - Split out the category logic out of the TraceLog into CategoryRegistry. Makes it easier to unbundle, reuse and reason about. - Get rid of the parallel arrays for tracking names, filters and state of each category and switch them to one array of struct. This not only makes the code easier to read, but also opens the way for having categories defined at compile time that don't need any lazy initialization of the "enabled" ptr. - Naming cleanup: the term "category group" has always been confusing. All it does is reflecting a subtle implementation detail (the fact that a category name can be "cat1,cat2") which is quite irrelevant from a functional viewpoint. BUG=659689 ==========
Message was sent while issue was closed.
Committed patchset #6 (id:240001)
Message was sent while issue was closed.
Description was changed from ========== tracing: split out the CategoryRegistry from the TraceLog Changes introduced by this CL: - Split out the category logic out of the TraceLog into CategoryRegistry. Makes it easier to unbundle, reuse and reason about. - Get rid of the parallel arrays for tracking names, filters and state of each category and switch them to one array of struct. This not only makes the code easier to read, but also opens the way for having categories defined at compile time that don't need any lazy initialization of the "enabled" ptr. - Naming cleanup: the term "category group" has always been confusing. All it does is reflecting a subtle implementation detail (the fact that a category name can be "cat1,cat2") which is quite irrelevant from a functional viewpoint. BUG=659689 ========== to ========== tracing: split out the CategoryRegistry from the TraceLog Changes introduced by this CL: - Split out the category logic out of the TraceLog into CategoryRegistry. Makes it easier to unbundle, reuse and reason about. - Get rid of the parallel arrays for tracking names, filters and state of each category and switch them to one array of struct. This not only makes the code easier to read, but also opens the way for having categories defined at compile time that don't need any lazy initialization of the "enabled" ptr. - Naming cleanup: the term "category group" has always been confusing. All it does is reflecting a subtle implementation detail (the fact that a category name can be "cat1,cat2") which is quite irrelevant from a functional viewpoint. BUG=659689 Committed: https://crrev.com/094ac7f87d78a80e3934e148855a908977559166 Cr-Commit-Position: refs/heads/master@{#431300} ==========
Message was sent while issue was closed.
Patchset 6 (id:??) landed as https://crrev.com/094ac7f87d78a80e3934e148855a908977559166 Cr-Commit-Position: refs/heads/master@{#431300}
Message was sent while issue was closed.
lgtm! |