|
|
Created:
5 years, 8 months ago by Dan Beam Modified:
5 years, 7 months ago CC:
chromium-reviews, wfh+watch_chromium.org, erikwright+watch_chromium.org Base URL:
https://chromium.googlesource.com/chromium/src.git@do-initialize Target Ref:
refs/pending/heads/master Project:
chromium Visibility:
Public. |
DescriptionAdd granular file tracing.
R=thestig@chromium.org,nduca@chromium.org
BUG=480665
Committed: https://crrev.com/492dc31b433656444c9c74213a133c19c8ebfa21
Cr-Commit-Position: refs/heads/master@{#329114}
Patch Set 1 : based on master #Patch Set 2 : add async file tracing #
Total comments: 12
Patch Set 3 : TRACE_EVENT* #
Total comments: 9
Patch Set 4 : take 2 #
Total comments: 9
Patch Set 5 : add TRACE_EVENT_ID* #Patch Set 6 : herp #
Total comments: 2
Patch Set 7 : asdf #
Total comments: 1
Patch Set 8 : win fixes #
Total comments: 8
Patch Set 9 : TraceEnabler #Patch Set 10 : remove some ; from end of macros #Patch Set 11 : actually compiles :D #
Total comments: 4
Patch Set 12 : thestig@ review #
Total comments: 2
Patch Set 13 : comment #
Messages
Total messages: 97 (46 generated)
Patchset #1 (id:1) has been deleted
Patchset #1 (id:20001) has been deleted
Patchset #2 (id:60001) has been deleted
Patchset #1 (id:40001) has been deleted
Patchset #2 (id:100001) has been deleted
Patchset #3 (id:140001) has been deleted
Patchset #2 (id:120001) has been deleted
Patchset #3 (id:170001) has been deleted
screenshots: http://imgur.com/a/dM3U1 shared traces internally with folks via drive (they were too big to attachment to the bug). https://codereview.chromium.org/1072133006/diff/160001/base/files/file.cc File base/files/file.cc (right): https://codereview.chromium.org/1072133006/diff/160001/base/files/file.cc#new... base/files/file.cc:98: "path", path_.AsUTF8Unsafe()); this seemed like the sanest place to start this, but open to suggestions... https://codereview.chromium.org/1072133006/diff/160001/base/trace_event/scope... File base/trace_event/scoped_file_trace.h (right): https://codereview.chromium.org/1072133006/diff/160001/base/trace_event/scope... base/trace_event/scoped_file_trace.h:34: static const char kGroup[]; don't really care where this lives; it's arguable it should be reversed (base::File::kTraceGroup and it's used here).
https://codereview.chromium.org/1072133006/diff/160001/base/files/file_win.cc File base/files/file_win.cc (right): https://codereview.chromium.org/1072133006/diff/160001/base/files/file_win.cc... base/files/file_win.cc:135: ScopedFileTrace trace(path_, "WriteAtCurrentPos", size); It's also arguable that we'd just want these all to be "Write" (same with "ReadAtCurrentPos"). https://codereview.chromium.org/1072133006/diff/160001/base/files/file_win.cc... base/files/file_win.cc:165: ScopedFileTrace trace(path_, "SetLength", length); Also, should I be passing length here? https://codereview.chromium.org/1072133006/diff/160001/base/trace_event/scope... File base/trace_event/scoped_file_trace.h (right): https://codereview.chromium.org/1072133006/diff/160001/base/trace_event/scope... base/trace_event/scoped_file_trace.h:38: std::string path_; Note to self: const https://codereview.chromium.org/1072133006/diff/160001/base/trace_event/scope... base/trace_event/scoped_file_trace.h:44: size_t bytes_; Also const if it's too hard to update with real byte amount later
skyostil@chromium.org changed reviewers: + skyostil@chromium.org
https://codereview.chromium.org/1072133006/diff/160001/base/trace_event/scope... File base/trace_event/scoped_file_trace.cc (right): https://codereview.chromium.org/1072133006/diff/160001/base/trace_event/scope... base/trace_event/scoped_file_trace.cc:17: : path_(path.AsUTF8Unsafe()), event_(event), bytes_(bytes) { This causes some string copying and memory allocation churn even if tracing is disabled. Could we avoid that somehow?
https://codereview.chromium.org/1072133006/diff/160001/base/trace_event/scope... File base/trace_event/scoped_file_trace.cc (right): https://codereview.chromium.org/1072133006/diff/160001/base/trace_event/scope... base/trace_event/scoped_file_trace.cc:17: : path_(path.AsUTF8Unsafe()), event_(event), bytes_(bytes) { On 2015/04/24 10:42:55, Sami wrote: > This causes some string copying and memory allocation churn even if tracing is > disabled. Could we avoid that somehow? How is tracing disabled? At compile time or runtime? There's a couple things we could do. Compile-time: #if !defined(ENABLE_TRACING) ScopedFileTrace::ScopedFileTrace( const FilePath& path, const char* event, size_t bytes) {} ScopedFileTrace::~ScopedFileTrace() {} #else ... functional code ... #endif would probably be the easiest if this gets stripped out by the compiler. Runtime: ScopedFileTrace::ScopedFileTrace( const FilePath& path, const char* event, size_t bytes) { if (IsTracingOn()) { event_ = event; ... } else { event_ = nullptr; } } ScopedFileTrace::~ScopedFileTrace() { if (event_) { // instead of IsTracingOn() ... } } Seems like the best way as it only stack allocates 1 size_t, 1 pointer (only set once), and 1 empty string (maybe 1 pointer? not sure). Is this sufficient? We could try to employ some hacks with heap allocation or use const refs because these are all used in the same scope but these seem like premature optimizations (and more prone to use-after-free). I agree we shouldn't copy and/or convert the path from UTF-8 (which will be from wide on windows, I believe).
https://codereview.chromium.org/1072133006/diff/160001/base/trace_event/scope... File base/trace_event/scoped_file_trace.cc (right): https://codereview.chromium.org/1072133006/diff/160001/base/trace_event/scope... base/trace_event/scoped_file_trace.cc:17: : path_(path.AsUTF8Unsafe()), event_(event), bytes_(bytes) { On 2015/04/24 16:37:19, Dan Beam wrote: > On 2015/04/24 10:42:55, Sami wrote: > > This causes some string copying and memory allocation churn even if tracing is > > disabled. Could we avoid that somehow? > > How is tracing disabled? At compile time or runtime? > > There's a couple things we could do. Compile-time: > > #if !defined(ENABLE_TRACING) > > ScopedFileTrace::ScopedFileTrace( > const FilePath& path, const char* event, size_t bytes) {} > ScopedFileTrace::~ScopedFileTrace() {} > > #else > ... functional code ... > #endif > > would probably be the easiest if this gets stripped out by the compiler. > > Runtime: > > ScopedFileTrace::ScopedFileTrace( > const FilePath& path, const char* event, size_t bytes) { > if (IsTracingOn()) { > event_ = event; > ... > } else { > event_ = nullptr; > } > } > ScopedFileTrace::~ScopedFileTrace() { > if (event_) { // instead of IsTracingOn() > ... > } > } > > Seems like the best way as it only stack allocates 1 size_t, 1 pointer (only set > once), and 1 empty string (maybe 1 pointer? not sure). > > Is this sufficient? We could try to employ some hacks with heap allocation or > use const refs because these are all used in the same scope but these seem like > premature optimizations (and more prone to use-after-free). > > I agree we shouldn't copy and/or convert the path from UTF-8 (which will be from > wide on windows, I believe). Or we could just add a bool tracing_enabled_.
https://codereview.chromium.org/1072133006/diff/160001/base/trace_event/scope... File base/trace_event/scoped_file_trace.cc (right): https://codereview.chromium.org/1072133006/diff/160001/base/trace_event/scope... base/trace_event/scoped_file_trace.cc:17: : path_(path.AsUTF8Unsafe()), event_(event), bytes_(bytes) { On 2015/04/24 16:37:19, Dan Beam wrote: > On 2015/04/24 10:42:55, Sami wrote: > > This causes some string copying and memory allocation churn even if tracing is > > disabled. Could we avoid that somehow? > > How is tracing disabled? At compile time or runtime? > > There's a couple things we could do. Compile-time: > > #if !defined(ENABLE_TRACING) > > ScopedFileTrace::ScopedFileTrace( > const FilePath& path, const char* event, size_t bytes) {} > ScopedFileTrace::~ScopedFileTrace() {} > > #else > ... functional code ... > #endif > > would probably be the easiest if this gets stripped out by the compiler. > > Runtime: > > ScopedFileTrace::ScopedFileTrace( > const FilePath& path, const char* event, size_t bytes) { > if (IsTracingOn()) { > event_ = event; > ... > } else { > event_ = nullptr; > } > } > ScopedFileTrace::~ScopedFileTrace() { > if (event_) { // instead of IsTracingOn() > ... > } > } > > Seems like the best way as it only stack allocates 1 size_t, 1 pointer (only set > once), and 1 empty string (maybe 1 pointer? not sure). > > Is this sufficient? We could try to employ some hacks with heap allocation or > use const refs because these are all used in the same scope but these seem like > premature optimizations (and more prone to use-after-free). > > I agree we shouldn't copy and/or convert the path from UTF-8 (which will be from > wide on windows, I believe). Tracing is enabled at runtime and included in all builds. You can check if tracing is enabled via TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED. However, note that TRACE_EVENT() is already scoped and won't evaluate its arguments unless tracing is enabled, so it seems like we could just replace ScopedFileTrace with a corresponding TRACE_EVENT macro invocation like most other subsystems do. WDYT?
https://codereview.chromium.org/1072133006/diff/160001/base/trace_event/scope... File base/trace_event/scoped_file_trace.cc (right): https://codereview.chromium.org/1072133006/diff/160001/base/trace_event/scope... base/trace_event/scoped_file_trace.cc:17: : path_(path.AsUTF8Unsafe()), event_(event), bytes_(bytes) { On 2015/04/24 16:45:41, Sami wrote: > On 2015/04/24 16:37:19, Dan Beam wrote: > > On 2015/04/24 10:42:55, Sami wrote: > > > This causes some string copying and memory allocation churn even if tracing > is > > > disabled. Could we avoid that somehow? > > > > How is tracing disabled? At compile time or runtime? > > > > There's a couple things we could do. Compile-time: > > > > #if !defined(ENABLE_TRACING) > > > > ScopedFileTrace::ScopedFileTrace( > > const FilePath& path, const char* event, size_t bytes) {} > > ScopedFileTrace::~ScopedFileTrace() {} > > > > #else > > ... functional code ... > > #endif > > > > would probably be the easiest if this gets stripped out by the compiler. > > > > Runtime: > > > > ScopedFileTrace::ScopedFileTrace( > > const FilePath& path, const char* event, size_t bytes) { > > if (IsTracingOn()) { > > event_ = event; > > ... > > } else { > > event_ = nullptr; > > } > > } > > ScopedFileTrace::~ScopedFileTrace() { > > if (event_) { // instead of IsTracingOn() > > ... > > } > > } > > > > Seems like the best way as it only stack allocates 1 size_t, 1 pointer (only > set > > once), and 1 empty string (maybe 1 pointer? not sure). > > > > Is this sufficient? We could try to employ some hacks with heap allocation or > > use const refs because these are all used in the same scope but these seem > like > > premature optimizations (and more prone to use-after-free). > > > > I agree we shouldn't copy and/or convert the path from UTF-8 (which will be > from > > wide on windows, I believe). > > Tracing is enabled at runtime and included in all builds. You can check if > tracing is enabled via TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED. > > However, note that TRACE_EVENT() is already scoped and won't evaluate its > arguments unless tracing is enabled, so it seems like we could just replace > ScopedFileTrace with a corresponding TRACE_EVENT macro invocation like most > other subsystems do. WDYT? We could if we want to duplicate some macros or rewrite base::File to have less if (...) { return ...; } code paths. there's about 16 of these currently.
https://codereview.chromium.org/1072133006/diff/160001/base/trace_event/scope... File base/trace_event/scoped_file_trace.cc (right): https://codereview.chromium.org/1072133006/diff/160001/base/trace_event/scope... base/trace_event/scoped_file_trace.cc:17: : path_(path.AsUTF8Unsafe()), event_(event), bytes_(bytes) { On 2015/04/24 17:29:50, Dan Beam wrote: > On 2015/04/24 16:45:41, Sami wrote: > > On 2015/04/24 16:37:19, Dan Beam wrote: > > > On 2015/04/24 10:42:55, Sami wrote: > > > > This causes some string copying and memory allocation churn even if > tracing > > is > > > > disabled. Could we avoid that somehow? > > > > > > How is tracing disabled? At compile time or runtime? > > > > > > There's a couple things we could do. Compile-time: > > > > > > #if !defined(ENABLE_TRACING) > > > > > > ScopedFileTrace::ScopedFileTrace( > > > const FilePath& path, const char* event, size_t bytes) {} > > > ScopedFileTrace::~ScopedFileTrace() {} > > > > > > #else > > > ... functional code ... > > > #endif > > > > > > would probably be the easiest if this gets stripped out by the compiler. > > > > > > Runtime: > > > > > > ScopedFileTrace::ScopedFileTrace( > > > const FilePath& path, const char* event, size_t bytes) { > > > if (IsTracingOn()) { > > > event_ = event; > > > ... > > > } else { > > > event_ = nullptr; > > > } > > > } > > > ScopedFileTrace::~ScopedFileTrace() { > > > if (event_) { // instead of IsTracingOn() > > > ... > > > } > > > } > > > > > > Seems like the best way as it only stack allocates 1 size_t, 1 pointer (only > > set > > > once), and 1 empty string (maybe 1 pointer? not sure). > > > > > > Is this sufficient? We could try to employ some hacks with heap allocation > or > > > use const refs because these are all used in the same scope but these seem > > like > > > premature optimizations (and more prone to use-after-free). > > > > > > I agree we shouldn't copy and/or convert the path from UTF-8 (which will be > > from > > > wide on windows, I believe). > > > > Tracing is enabled at runtime and included in all builds. You can check if > > tracing is enabled via TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED. > > > > However, note that TRACE_EVENT() is already scoped and won't evaluate its > > arguments unless tracing is enabled, so it seems like we could just replace > > ScopedFileTrace with a corresponding TRACE_EVENT macro invocation like most > > other subsystems do. WDYT? > > We could if we want to duplicate some macros or rewrite base::File to have less > if (...) { return ...; } code paths. there's about 16 of these currently. I'm not sure I follow? TRACE_EVENT<N> works fine with early returns, e.g: { TRACE_EVENT0("category", "event"); if (x > y) { return; } SomeOperation(); } The event will either be ended at the return statement or after SomeOperation() depending on which branch is taken, similar to ScopedFiledTrace.
On 2015/04/24 17:34:47, Sami wrote: > https://codereview.chromium.org/1072133006/diff/160001/base/trace_event/scope... > File base/trace_event/scoped_file_trace.cc (right): > > https://codereview.chromium.org/1072133006/diff/160001/base/trace_event/scope... > base/trace_event/scoped_file_trace.cc:17: : path_(path.AsUTF8Unsafe()), > event_(event), bytes_(bytes) { > On 2015/04/24 17:29:50, Dan Beam wrote: > > On 2015/04/24 16:45:41, Sami wrote: > > > On 2015/04/24 16:37:19, Dan Beam wrote: > > > > On 2015/04/24 10:42:55, Sami wrote: > > > > > This causes some string copying and memory allocation churn even if > > tracing > > > is > > > > > disabled. Could we avoid that somehow? > > > > > > > > How is tracing disabled? At compile time or runtime? > > > > > > > > There's a couple things we could do. Compile-time: > > > > > > > > #if !defined(ENABLE_TRACING) > > > > > > > > ScopedFileTrace::ScopedFileTrace( > > > > const FilePath& path, const char* event, size_t bytes) {} > > > > ScopedFileTrace::~ScopedFileTrace() {} > > > > > > > > #else > > > > ... functional code ... > > > > #endif > > > > > > > > would probably be the easiest if this gets stripped out by the compiler. > > > > > > > > Runtime: > > > > > > > > ScopedFileTrace::ScopedFileTrace( > > > > const FilePath& path, const char* event, size_t bytes) { > > > > if (IsTracingOn()) { > > > > event_ = event; > > > > ... > > > > } else { > > > > event_ = nullptr; > > > > } > > > > } > > > > ScopedFileTrace::~ScopedFileTrace() { > > > > if (event_) { // instead of IsTracingOn() > > > > ... > > > > } > > > > } > > > > > > > > Seems like the best way as it only stack allocates 1 size_t, 1 pointer > (only > > > set > > > > once), and 1 empty string (maybe 1 pointer? not sure). > > > > > > > > Is this sufficient? We could try to employ some hacks with heap > allocation > > or > > > > use const refs because these are all used in the same scope but these seem > > > like > > > > premature optimizations (and more prone to use-after-free). > > > > > > > > I agree we shouldn't copy and/or convert the path from UTF-8 (which will > be > > > from > > > > wide on windows, I believe). > > > > > > Tracing is enabled at runtime and included in all builds. You can check if > > > tracing is enabled via TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED. > > > > > > However, note that TRACE_EVENT() is already scoped and won't evaluate its > > > arguments unless tracing is enabled, so it seems like we could just replace > > > ScopedFileTrace with a corresponding TRACE_EVENT macro invocation like most > > > other subsystems do. WDYT? > > > > We could if we want to duplicate some macros or rewrite base::File to have > less > > if (...) { return ...; } code paths. there's about 16 of these currently. > > I'm not sure I follow? TRACE_EVENT<N> works fine with early returns, e.g: > > { > TRACE_EVENT0("category", "event"); > if (x > y) { > return; > } > SomeOperation(); > } > > The event will either be ended at the return statement or after SomeOperation() > depending on which branch is taken, similar to ScopedFiledTrace. oh, if we don't need BEGIN/END, sure that'll work.
updated to just use TRACE_EVENT*() macros https://codereview.chromium.org/1072133006/diff/190001/base/files/file.cc File base/files/file.cc (right): https://codereview.chromium.org/1072133006/diff/190001/base/files/file.cc#new... base/files/file.cc:75: "path", path_.AsUTF8Unsafe()); should I be passing along the path here?
dbeam@chromium.org changed reviewers: - skyostil@chromium.org, thestig@chromium.org
dbeam@chromium.org changed reviewers: + thestig@chromium.org - nduca@chromium.org
Moving nduca@ and skyostil@ to CC Ping thestig@
https://codereview.chromium.org/1072133006/diff/190001/base/files/file.cc File base/files/file.cc (right): https://codereview.chromium.org/1072133006/diff/190001/base/files/file.cc#new... base/files/file.cc:74: TRACE_EVENT_ASYNC_END1(kTraceGroup, "File", this, We may not always call TRACE_EVENT_ASYNC_BEGIN1() in Initialize(), would that mismatch cause trouble here? https://codereview.chromium.org/1072133006/diff/190001/base/files/file.cc#new... base/files/file.cc:83: created_ = other.object->created(); Set |path_| here too? https://codereview.chromium.org/1072133006/diff/190001/base/files/file_posix.cc File base/files/file_posix.cc (right): https://codereview.chromium.org/1072133006/diff/190001/base/files/file_posix.... base/files/file_posix.cc:585: #else how about: { #if defined(OS_NACL) ... return; #elif defined(OS_LINUX) || defined(OS_ANDROID) #define FLUSHFUNC fdatasync #else #define FLUSHFUNC fsync #endif TRACE_EVENT() return !HANDLE_EINTR(FLUSHFUNC(file_.get())); }
https://codereview.chromium.org/1072133006/diff/190001/base/files/file.cc File base/files/file.cc (right): https://codereview.chromium.org/1072133006/diff/190001/base/files/file.cc#new... base/files/file.cc:74: TRACE_EVENT_ASYNC_END1(kTraceGroup, "File", this, On 2015/04/27 22:55:55, Lei Zhang wrote: > We may not always call TRACE_EVENT_ASYNC_BEGIN1() in Initialize(), would that > mismatch cause trouble here? not sure but just made this TRACE_EVENT_ASYNC_{BEGIN/END}0 instead and just passing |this| (omitting path_) https://codereview.chromium.org/1072133006/diff/190001/base/files/file.cc#new... base/files/file.cc:83: created_ = other.object->created(); On 2015/04/27 22:55:55, Lei Zhang wrote: > Set |path_| here too? Done. https://codereview.chromium.org/1072133006/diff/190001/base/files/file_posix.cc File base/files/file_posix.cc (right): https://codereview.chromium.org/1072133006/diff/190001/base/files/file_posix.... base/files/file_posix.cc:585: #else On 2015/04/27 22:55:55, Lei Zhang wrote: > how about: > > { > #if defined(OS_NACL) > ... > return; > #elif defined(OS_LINUX) || defined(OS_ANDROID) > #define FLUSHFUNC fdatasync > #else > #define FLUSHFUNC fsync > #endif > TRACE_EVENT() > return !HANDLE_EINTR(FLUSHFUNC(file_.get())); > } Done.
It'll probably be good to get the blessing from some tracing folks, but otherwise looks good once you undo my bad advice. https://codereview.chromium.org/1072133006/diff/190001/base/files/file_posix.cc File base/files/file_posix.cc (right): https://codereview.chromium.org/1072133006/diff/190001/base/files/file_posix.... base/files/file_posix.cc:585: #else On 2015/04/28 03:17:11, Dan Beam wrote: > On 2015/04/27 22:55:55, Lei Zhang wrote: > > how about: > > > > { > > #if defined(OS_NACL) > > ... > > return; > > #elif defined(OS_LINUX) || defined(OS_ANDROID) > > #define FLUSHFUNC fdatasync > > #else > > #define FLUSHFUNC fsync > > #endif > > TRACE_EVENT() > > return !HANDLE_EINTR(FLUSHFUNC(file_.get())); > > } > > Done. Oh, sorry for the bad advice. OS_NACL will still try to compile the code even though it's not reachable.
Patchset #4 (id:210001) has been deleted
Patchset #4 (id:230001) has been deleted
https://codereview.chromium.org/1072133006/diff/190001/base/files/file_posix.cc File base/files/file_posix.cc (right): https://codereview.chromium.org/1072133006/diff/190001/base/files/file_posix.... base/files/file_posix.cc:585: #else On 2015/04/28 03:53:26, Lei Zhang wrote: > On 2015/04/28 03:17:11, Dan Beam wrote: > > On 2015/04/27 22:55:55, Lei Zhang wrote: > > > how about: > > > > > > { > > > #if defined(OS_NACL) > > > ... > > > return; > > > #elif defined(OS_LINUX) || defined(OS_ANDROID) > > > #define FLUSHFUNC fdatasync > > > #else > > > #define FLUSHFUNC fsync > > > #endif > > > TRACE_EVENT() > > > return !HANDLE_EINTR(FLUSHFUNC(file_.get())); > > > } > > > > Done. > > Oh, sorry for the bad advice. OS_NACL will still try to compile the code even > though it's not reachable. Reverted back to this code.
lgtm
skyostil@chromium.org changed reviewers: + skyostil@chromium.org
Tracing part lgtm -- assuming this produces useful looking traces :) https://codereview.chromium.org/1072133006/diff/250001/base/files/file.h File base/files/file.h (right): https://codereview.chromium.org/1072133006/diff/250001/base/files/file.h#newc... base/files/file.h:308: static const char kTraceGroup[]; nit: Usually we just write the trace category explicitly in each trace event. It makes it easier to grep where trace events are coming from, and the compiler will fold the identical strings into one anyway.
https://codereview.chromium.org/1072133006/diff/250001/base/files/file.h File base/files/file.h (right): https://codereview.chromium.org/1072133006/diff/250001/base/files/file.h#newc... base/files/file.h:308: static const char kTraceGroup[]; On 2015/04/28 11:10:39, Sami wrote: > nit: Usually we just write the trace category explicitly in each trace event. It > makes it easier to grep where trace events are coming from, and the compiler > will fold the identical strings into one anyway. I guess I can do this, it's just... TRACE_DISABLED_BY_DEFAULT("file") is pretty long.
https://codereview.chromium.org/1072133006/diff/250001/base/files/file.h File base/files/file.h (right): https://codereview.chromium.org/1072133006/diff/250001/base/files/file.h#newc... base/files/file.h:308: static const char kTraceGroup[]; On 2015/04/28 15:47:58, Dan Beam wrote: > On 2015/04/28 11:10:39, Sami wrote: > > nit: Usually we just write the trace category explicitly in each trace event. > It > > makes it easier to grep where trace events are coming from, and the compiler > > will fold the identical strings into one anyway. > > I guess I can do this, it's just... TRACE_DISABLED_BY_DEFAULT("file") is pretty > long. I don't think it's a hard rule, so I'll leave it up to you to decide.
Drive-by, sorry :) https://codereview.chromium.org/1072133006/diff/250001/base/files/file.h File base/files/file.h (right): https://codereview.chromium.org/1072133006/diff/250001/base/files/file.h#newc... base/files/file.h:308: static const char kTraceGroup[]; On 2015/04/28 15:51:05, Sami wrote: > On 2015/04/28 15:47:58, Dan Beam wrote: > > On 2015/04/28 11:10:39, Sami wrote: > > > nit: Usually we just write the trace category explicitly in each trace > event. > > It > > > makes it easier to grep where trace events are coming from, and the compiler > > > will fold the identical strings into one anyway. > > > > I guess I can do this, it's just... TRACE_DISABLED_BY_DEFAULT("file") is > pretty > > long. > > I don't think it's a hard rule, so I'll leave it up to you to decide. I don't have a specific preference, but consider naming it kFileTraceGroup - this way we can still grep somewhat reliably. https://codereview.chromium.org/1072133006/diff/250001/base/files/file.h#newc... base/files/file.h:370: |unsafe_path_|, then? https://codereview.chromium.org/1072133006/diff/250001/base/files/file_posix.cc File base/files/file_posix.cc (right): https://codereview.chromium.org/1072133006/diff/250001/base/files/file_posix.... base/files/file_posix.cc:204: TRACE_EVENT2(kTraceGroup, "Read", "path", path_.AsUTF8Unsafe(), "size", size); Given that you call this every read/seek/etc, might be worth storing the UTF8 path name.
dbeam@chromium.org changed reviewers: + nduca@chromium.org
+nduca for base/trace_event/OWNERS skyostil/nduca: what do you think about TRACE_EVENT_ID*()? https://codereview.chromium.org/1072133006/diff/250001/base/files/file.h File base/files/file.h (right): https://codereview.chromium.org/1072133006/diff/250001/base/files/file.h#newc... base/files/file.h:308: static const char kTraceGroup[]; On 2015/04/28 20:26:54, groby wrote: > On 2015/04/28 15:51:05, Sami wrote: > > On 2015/04/28 15:47:58, Dan Beam wrote: > > > On 2015/04/28 11:10:39, Sami wrote: > > > > nit: Usually we just write the trace category explicitly in each trace > > event. > > > It > > > > makes it easier to grep where trace events are coming from, and the > compiler > > > > will fold the identical strings into one anyway. > > > > > > I guess I can do this, it's just... TRACE_DISABLED_BY_DEFAULT("file") is > > pretty > > > long. > > > > I don't think it's a hard rule, so I'll leave it up to you to decide. > > I don't have a specific preference, but consider naming it kFileTraceGroup - > this way we can still grep somewhat reliably. $ git grep \\bkTraceGroup\\b yields only these results reliably https://codereview.chromium.org/1072133006/diff/250001/base/files/file.h#newc... base/files/file.h:370: On 2015/04/28 20:26:54, groby wrote: > |unsafe_path_|, then? Done. https://codereview.chromium.org/1072133006/diff/250001/base/files/file_posix.cc File base/files/file_posix.cc (right): https://codereview.chromium.org/1072133006/diff/250001/base/files/file_posix.... base/files/file_posix.cc:204: TRACE_EVENT2(kTraceGroup, "Read", "path", path_.AsUTF8Unsafe(), "size", size); On 2015/04/28 20:26:55, groby wrote: > Given that you call this every read/seek/etc, might be worth storing the UTF8 > path name. this is only called while tracing (in which case all of chrome is equally slower)
https://codereview.chromium.org/1072133006/diff/290001/base/trace_event/trace... File base/trace_event/trace_event.h (right): https://codereview.chromium.org/1072133006/diff/290001/base/trace_event/trace... base/trace_event/trace_event.h:244: category_group, name, id, arg1_name, arg1_val) It's not clear what |id| refers to here. Does it need to match the ASYNC id? Could you upload a sample trace with this data in it just to get an idea of how this looks? I'm wondering if the NESTABLE_ASYNC event would be more appropriate.
nduca@chromium.org changed reviewers: + oysteine@chromium.org
i'm pretty confused what the ids are being used for. i still recommend using async events. oysteine might be able to advise since i'm a bit swamped this week.
On 2015/04/29 15:59:35, nduca wrote: > i'm pretty confused what the ids are being used for. i still recommend using > async events. oysteine might be able to advise since i'm a bit swamped this > week. This CL /does/ use async events (see: base/files/file.cc). Excuse the pseudo-code (written to save you time): File::File() { ASYNC_BEGIN(this); } File::~File() { ASYNC_END(this); } Now for every: File::Read() { ... } I'd like to associate with the same "id" (i.e. the same file instance), but doing this: File::Read() { ASYNC_BEGIN(this, "Read"); if (!cool_) { ASYNC_END(this, "Read"); return; } ... if (!nice_) { ASYNC_END(this, "Read"); return; } ... ASYNC_END(this, "Read"); } doesn't seem nearly as cool as relying on a scoped trace that can associate to an ID.
On 2015/04/29 15:59:35, nduca wrote: > i'm pretty confused what the ids are being used for. i still recommend using > async events. oysteine might be able to advise since i'm a bit swamped this > week. Looks to me like this is actually, in practice, doing what the NESTABLE_ASYNC_* APIs are supposed to be used for. The main new thing which (I think) hasn't been done before is that you're doing scoped events nested within the top level async one. dbeam: In practice this just means doing what you're already doing, but with a slightly different API. I think you want TRACE_EVENT_NESTABLE_ASYNC_BEGIN0/TRACE_EVENT_NESTABLE_ASYNC_END0 pairs in the File constructors/destructors, and then add TRACE_EVENT_NESTABLE1/2 instead of TRACE_EVENT_ID1/2.
On 2015/04/29 18:12:18, Oystein wrote: > On 2015/04/29 15:59:35, nduca wrote: > > i'm pretty confused what the ids are being used for. i still recommend using > > async events. oysteine might be able to advise since i'm a bit swamped this > > week. > > Looks to me like this is actually, in practice, doing what the NESTABLE_ASYNC_* > APIs are supposed to be used for. > > The main new thing which (I think) hasn't been done before is that you're doing > scoped events nested within the top level async one. exactly > > dbeam: In practice this just means doing what you're already doing, but with a > slightly different API. I think you want > TRACE_EVENT_NESTABLE_ASYNC_BEGIN0/TRACE_EVENT_NESTABLE_ASYNC_END0 pairs in the > File constructors/destructors, and then add TRACE_EVENT_NESTABLE1/2 instead of > TRACE_EVENT_ID1/2. alright, I'll change from TRACE_EVENT_ID* -> TRACE_EVENT_NESTABLE* (probably just a rename and slightly tweaking to my new macros).
dbeam@chromium.org changed reviewers: - oysteine@chromium.org
Patchset #7 (id:310001) has been deleted
Patchset #7 (id:330001) has been deleted
ok, let's try again by adding a scoped NESTABLE macro this time. this requires a viewer change[1], so sharing a trace isn't as useful as you'd still have to rebuild :(. [1] https://codereview.appspot.com/234940043/ https://codereview.chromium.org/1072133006/diff/290001/base/trace_event/trace... File base/trace_event/trace_event.h (right): https://codereview.chromium.org/1072133006/diff/290001/base/trace_event/trace... base/trace_event/trace_event.h:244: category_group, name, id, arg1_name, arg1_val) On 2015/04/29 15:01:51, Sami wrote: > It's not clear what |id| refers to here. Does it need to match the ASYNC id? yes > > Could you upload a sample trace with this data in it just to get an idea of how > this looks? I'm wondering if the NESTABLE_ASYNC event would be more appropriate. it probably is. shared a TRACE_EVENT_ID* version with everybody (before I try TRACE_EVENT_NESTABLE*). https://codereview.chromium.org/1072133006/diff/350001/base/trace_event/trace... File base/trace_event/trace_event.h (right): https://codereview.chromium.org/1072133006/diff/350001/base/trace_event/trace... base/trace_event/trace_event.h:1578: ScopedTracer() : initialized_(false) {} forgot i did this. can revert if you want...
i don't think we actually need the complete async event. we can make a scoped object that issues async begin and end events inside its constructor/destructor instead. it means making a separate class than what does the regular sync events but it's simpler. the only reason for the regular complete event is because there are so many begin-end events in a trace, adding the complete event saves bytes in the trace. i would prefer we only add more event phases when we absolutely need them.
dbeam@chromium.org changed reviewers: - skyostil@chromium.org
Patchset #8 (id:370001) has been deleted
Patchset #8 (id:390001) has been deleted
dbeam@chromium.org changed reviewers: + oysteine@chromium.org
+oysteine@ to review for nduca@ On 2015/04/30 15:28:21, nduca wrote: > i don't think we actually need the complete async event. we can make a scoped > object that issues async begin and end events inside its constructor/destructor > instead. it means making a separate class than what does the regular sync events > but it's simpler. Done. > > the only reason for the regular complete event is because there are so many > begin-end events in a trace, adding the complete event saves bytes in the trace. > i would prefer we only add more event phases when we absolutely need them. Removed and closed viewer CL.
I think this is looking pretty good now; minor points below. https://codereview.chromium.org/1072133006/diff/410001/base/files/file.cc File base/files/file.cc (right): https://codereview.chromium.org/1072133006/diff/410001/base/files/file.cc#new... base/files/file.cc:83: unsafe_path_ = path; What's the reason for setting this here, instead of setting it DoInitialize or at least after the ReferencesParent() check? I'm worried about codepaths popping up where the path gets used despite of Initialize() failing, not setting the member at all seems like a good layered defense. https://codereview.chromium.org/1072133006/diff/410001/base/files/file_tracing.h File base/files/file_tracing.h (right): https://codereview.chromium.org/1072133006/diff/410001/base/files/file_tracin... base/files/file_tracing.h:12: #define FILE_TRACING_PREFIX "base::File" I'm not sure if "base" is really adding any useful information to these events, but maybe I'm missing something. What was the reason for adding this? https://codereview.chromium.org/1072133006/diff/410001/base/files/file_tracin... base/files/file_tracing.h:24: bool category_enabled; \ nit: call the scope something other than "trace" (prefix with an underscore maybe?) and wrap the rest in {} so the macro doesn't pollute the function namespace unnecessarily.
https://codereview.chromium.org/1072133006/diff/410001/base/files/file.cc File base/files/file.cc (right): https://codereview.chromium.org/1072133006/diff/410001/base/files/file.cc#new... base/files/file.cc:25: FILE_TRACING_BEGIN(); It could be cleaner to do these BEGIN/END calls in a class member instead of duplicating them in all the constructors.
Patchset #9 (id:430001) has been deleted
https://codereview.chromium.org/1072133006/diff/410001/base/files/file.cc File base/files/file.cc (right): https://codereview.chromium.org/1072133006/diff/410001/base/files/file.cc#new... base/files/file.cc:25: FILE_TRACING_BEGIN(); On 2015/05/01 18:21:05, Oystein wrote: > It could be cleaner to do these BEGIN/END calls in a class member instead of > duplicating them in all the constructors. Done. https://codereview.chromium.org/1072133006/diff/410001/base/files/file.cc#new... base/files/file.cc:83: unsafe_path_ = path; On 2015/05/01 18:15:31, Oystein wrote: > What's the reason for setting this here, instead of setting it DoInitialize or > at least after the ReferencesParent() check? I'm worried about codepaths popping > up where the path gets used despite of Initialize() failing, not setting the > member at all seems like a good layered defense. Done. (originally my rationale was: it'd be weird to do thing.Initialize(path) -> thing.GetPath() be different, but path_ is never exposed) https://codereview.chromium.org/1072133006/diff/410001/base/files/file_tracing.h File base/files/file_tracing.h (right): https://codereview.chromium.org/1072133006/diff/410001/base/files/file_tracin... base/files/file_tracing.h:12: #define FILE_TRACING_PREFIX "base::File" On 2015/05/01 18:15:31, Oystein wrote: > I'm not sure if "base" is really adding any useful information to these events, > but maybe I'm missing something. What was the reason for adding this? just to match code, removed (noticed many places omit namespace) https://codereview.chromium.org/1072133006/diff/410001/base/files/file_tracin... base/files/file_tracing.h:24: bool category_enabled; \ On 2015/05/01 18:15:31, Oystein wrote: > nit: call the scope something other than "trace" (prefix with an underscore > maybe?) and wrap the rest in {} so the macro doesn't pollute the function > namespace unnecessarily. Done.
Patchset #10 (id:470001) has been deleted
On 2015/05/01 23:29:04, Dan Beam wrote: > https://codereview.chromium.org/1072133006/diff/410001/base/files/file.cc > File base/files/file.cc (right): > > https://codereview.chromium.org/1072133006/diff/410001/base/files/file.cc#new... > base/files/file.cc:25: FILE_TRACING_BEGIN(); > On 2015/05/01 18:21:05, Oystein wrote: > > It could be cleaner to do these BEGIN/END calls in a class member instead of > > duplicating them in all the constructors. > > Done. > > https://codereview.chromium.org/1072133006/diff/410001/base/files/file.cc#new... > base/files/file.cc:83: unsafe_path_ = path; > On 2015/05/01 18:15:31, Oystein wrote: > > What's the reason for setting this here, instead of setting it DoInitialize or > > at least after the ReferencesParent() check? I'm worried about codepaths > popping > > up where the path gets used despite of Initialize() failing, not setting the > > member at all seems like a good layered defense. > > Done. (originally my rationale was: it'd be weird to do thing.Initialize(path) > -> thing.GetPath() be different, but path_ is never exposed) > > https://codereview.chromium.org/1072133006/diff/410001/base/files/file_tracing.h > File base/files/file_tracing.h (right): > > https://codereview.chromium.org/1072133006/diff/410001/base/files/file_tracin... > base/files/file_tracing.h:12: #define FILE_TRACING_PREFIX "base::File" > On 2015/05/01 18:15:31, Oystein wrote: > > I'm not sure if "base" is really adding any useful information to these > events, > > but maybe I'm missing something. What was the reason for adding this? > > just to match code, removed (noticed many places omit namespace) > > https://codereview.chromium.org/1072133006/diff/410001/base/files/file_tracin... > base/files/file_tracing.h:24: bool category_enabled; \ > On 2015/05/01 18:15:31, Oystein wrote: > > nit: call the scope something other than "trace" (prefix with an underscore > > maybe?) and wrap the rest in {} so the macro doesn't pollute the function > > namespace unnecessarily. > > Done. This looks pretty solid to me :). non-owner lgtm!
lgtm but you'll need some base/ owner
The CQ bit was checked by dbeam@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from thestig@chromium.org, skyostil@chromium.org Link to the patchset: https://codereview.chromium.org/1072133006/#ps490001 (title: "remove some ; from end of macros")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1072133006/490001
Message was sent while issue was closed.
Committed patchset #10 (id:490001)
Message was sent while issue was closed.
Patchset 10 (id:??) landed as https://crrev.com/a6e05c977096a03774e5406d63ad80c0166f9adc Cr-Commit-Position: refs/heads/master@{#328153}
Message was sent while issue was closed.
A revert of this CL (patchset #10 id:490001) has been created in https://codereview.chromium.org/1127713004/ by dbeam@chromium.org. The reason for reverting is: See if this broke sizes by increasing setup.exe by 0.43%..
Patchset #12 (id:530001) has been deleted
Patchset #15 (id:610001) has been deleted
Patchset #14 (id:590001) has been deleted
Patchset #13 (id:570001) has been deleted
Patchset #12 (id:550001) has been deleted
Patchset #11 (id:510001) has been deleted
Patchset #11 (id:630001) has been deleted
Patchset #11 (id:650001) has been deleted
Patchset #12 (id:690001) has been deleted
Patchset #11 (id:670001) has been deleted
Patchset #11 (id:710001) has been deleted
oysteine@: how 'bout this?
Patchset #11 (id:730001) has been deleted
Patchset #12 (id:770001) has been deleted
On 2015/05/07 05:29:29, Dan Beam wrote: > oysteine@: how 'bout this? Tracing part still lgtm from me, but I think the base/ part has changed enough that skyostil@/thestig@ may want to glance over it again.
https://codereview.chromium.org/1072133006/diff/750001/base/files/file_tracing.h File base/files/file_tracing.h (right): https://codereview.chromium.org/1072133006/diff/750001/base/files/file_tracin... base/files/file_tracing.h:52: static Provider* g_provider; Can you have a static SetProvider() method instead of exposing this? https://codereview.chromium.org/1072133006/diff/750001/base/files/file_tracin... base/files/file_tracing.h:67: bool ShouldInitialize() const; Any reason to have this separated from Initialize()?
https://codereview.chromium.org/1072133006/diff/750001/base/files/file_tracing.h File base/files/file_tracing.h (right): https://codereview.chromium.org/1072133006/diff/750001/base/files/file_tracin... base/files/file_tracing.h:52: static Provider* g_provider; On 2015/05/08 17:40:19, Lei Zhang wrote: > Can you have a static SetProvider() method instead of exposing this? Done. https://codereview.chromium.org/1072133006/diff/750001/base/files/file_tracin... base/files/file_tracing.h:67: bool ShouldInitialize() const; On 2015/05/08 17:40:19, Lei Zhang wrote: > Any reason to have this separated from Initialize()? less work is done in the common case that the category isn't enabled (only the category is checked and 1 boolean is initialized). also, it'd be odd to call Initialize() and have initialized_ be false later. i could change things around, but I don't see why it's better...
lgtm https://codereview.chromium.org/1072133006/diff/790001/content/browser/tracin... File content/browser/tracing/tracing_controller_impl.cc (right): https://codereview.chromium.org/1072133006/diff/790001/content/browser/tracin... content/browser/tracing/tracing_controller_impl.cc:61: base::FileTracing::SetProvider(new FileTracingProviderImpl); Can you mention you are deliberately leaking this?
https://codereview.chromium.org/1072133006/diff/790001/content/browser/tracin... File content/browser/tracing/tracing_controller_impl.cc (right): https://codereview.chromium.org/1072133006/diff/790001/content/browser/tracin... content/browser/tracing/tracing_controller_impl.cc:61: base::FileTracing::SetProvider(new FileTracingProviderImpl); On 2015/05/08 19:30:30, Lei Zhang wrote: > Can you mention you are deliberately leaking this? Done.
The CQ bit was checked by dbeam@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from nduca@chromium.org, skyostil@chromium.org, oysteine@chromium.org, thestig@chromium.org Link to the patchset: https://codereview.chromium.org/1072133006/#ps810001 (title: "comment")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1072133006/810001
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: linux_chromium_chromeos_rel_ng on tryserver.chromium.linux (JOB_TIMED_OUT, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
The CQ bit was checked by thestig@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1072133006/810001
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: chromium_presubmit on tryserver.chromium.linux (JOB_TIMED_OUT, no build URL)
The CQ bit was checked by dbeam@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1072133006/810001
Message was sent while issue was closed.
Committed patchset #13 (id:810001)
Message was sent while issue was closed.
Patchset 13 (id:??) landed as https://crrev.com/492dc31b433656444c9c74213a133c19c8ebfa21 Cr-Commit-Position: refs/heads/master@{#329114} |