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

Side by Side Diff: chrome/browser/sync/syncable/syncable.cc

Issue 8573011: Event tracing for sync events (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use simpler TRACE_EVENT macros Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/sync/syncable/syncable.h" 5 #include "chrome/browser/sync/syncable/syncable.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cstring> 8 #include <cstring>
9 #include <functional> 9 #include <functional>
10 #include <iomanip> 10 #include <iomanip>
11 #include <iterator> 11 #include <iterator>
12 #include <limits> 12 #include <limits>
13 #include <set> 13 #include <set>
14 #include <string> 14 #include <string>
15 15
16 #include "base/debug/trace_event.h"
16 #include "base/compiler_specific.h" 17 #include "base/compiler_specific.h"
17 #include "base/file_util.h" 18 #include "base/file_util.h"
18 #include "base/hash_tables.h" 19 #include "base/hash_tables.h"
19 #include "base/location.h" 20 #include "base/location.h"
20 #include "base/logging.h" 21 #include "base/logging.h"
21 #include "base/memory/scoped_ptr.h" 22 #include "base/memory/scoped_ptr.h"
22 #include "base/perftimer.h" 23 #include "base/perftimer.h"
23 #include "base/stl_util.h" 24 #include "base/stl_util.h"
24 #include "base/string_number_conversions.h" 25 #include "base/string_number_conversions.h"
25 #include "base/string_util.h" 26 #include "base/string_util.h"
(...skipping 1095 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 // ScopedKernelLock 1122 // ScopedKernelLock
1122 1123
1123 ScopedKernelLock::ScopedKernelLock(const Directory* dir) 1124 ScopedKernelLock::ScopedKernelLock(const Directory* dir)
1124 : scoped_lock_(dir->kernel_->mutex), dir_(const_cast<Directory*>(dir)) { 1125 : scoped_lock_(dir->kernel_->mutex), dir_(const_cast<Directory*>(dir)) {
1125 } 1126 }
1126 1127
1127 /////////////////////////////////////////////////////////////////////////// 1128 ///////////////////////////////////////////////////////////////////////////
1128 // Transactions 1129 // Transactions
1129 1130
1130 void BaseTransaction::Lock() { 1131 void BaseTransaction::Lock() {
1131 base::TimeTicks start_time = base::TimeTicks::Now(); 1132 TRACE_EVENT2("sync_lock_contention", "AcquireLock",
1133 "src_file", from_here_.file_name(),
1134 "src_func", from_here_.function_name());
1132 1135
1133 dirkernel_->transaction_mutex.Acquire(); 1136 dirkernel_->transaction_mutex.Acquire();
1134
1135 time_acquired_ = base::TimeTicks::Now();
1136 const base::TimeDelta elapsed = time_acquired_ - start_time;
1137 VLOG_LOC(from_here_, 2)
1138 << name_ << " transaction waited "
1139 << elapsed.InSecondsF() << " seconds.";
1140 } 1137 }
1141 1138
1142 void BaseTransaction::Unlock() { 1139 void BaseTransaction::Unlock() {
1143 dirkernel_->transaction_mutex.Release(); 1140 dirkernel_->transaction_mutex.Release();
1144 const base::TimeDelta elapsed = base::TimeTicks::Now() - time_acquired_;
1145 VLOG_LOC(from_here_, 2)
1146 << name_ << " transaction completed in " << elapsed.InSecondsF()
1147 << " seconds.";
1148 } 1141 }
1149 1142
1150 BaseTransaction::BaseTransaction(const tracked_objects::Location& from_here, 1143 BaseTransaction::BaseTransaction(const tracked_objects::Location& from_here,
1151 const char* name, 1144 const char* name,
1152 WriterTag writer, 1145 WriterTag writer,
1153 Directory* directory) 1146 Directory* directory)
1154 : from_here_(from_here), name_(name), writer_(writer), 1147 : from_here_(from_here), name_(name), writer_(writer),
1155 directory_(directory), dirkernel_(directory->kernel_) { 1148 directory_(directory), dirkernel_(directory->kernel_) {
1156 dirkernel_->observers->Notify( 1149 dirkernel_->observers->Notify(
1157 &TransactionObserver::OnTransactionStart, from_here_, writer_); 1150 &TransactionObserver::OnTransactionStart, from_here_, writer_);
1158 } 1151 }
1159 1152
1160 BaseTransaction::~BaseTransaction() { 1153 BaseTransaction::~BaseTransaction() {
1161 dirkernel_->observers->Notify( 1154 dirkernel_->observers->Notify(
1162 &TransactionObserver::OnTransactionEnd, from_here_, writer_); 1155 &TransactionObserver::OnTransactionEnd, from_here_, writer_);
1163 } 1156 }
1164 1157
1165 ReadTransaction::ReadTransaction(const tracked_objects::Location& location, 1158 ReadTransaction::ReadTransaction(const tracked_objects::Location& location,
1166 Directory* directory) 1159 Directory* directory)
1167 : BaseTransaction(location, "Read", INVALID, directory) { 1160 : BaseTransaction(location, "Read", INVALID, directory) {
1161 TRACE_EVENT_BEGIN2("sync", "ReadTransaction",
akalin 2011/11/17 03:27:21 What about adding the trace events to BaseTransact
rlarocque 2011/11/17 19:37:53 I originally wanted to do it that way, but couldn'
akalin 2011/11/17 22:17:45 I'm not sure what you mean; my suggestion doesn't
1162 "src_file", from_here_.file_name(),
1163 "src_func", from_here_.function_name());
1168 Lock(); 1164 Lock();
1169 } 1165 }
1170 1166
1171 ReadTransaction::ReadTransaction(const tracked_objects::Location& location, 1167 ReadTransaction::ReadTransaction(const tracked_objects::Location& location,
1172 const ScopedDirLookup& scoped_dir) 1168 const ScopedDirLookup& scoped_dir)
1173 : BaseTransaction(location, "Read", INVALID, scoped_dir.operator->()) { 1169 : BaseTransaction(location, "Read", INVALID, scoped_dir.operator->()) {
1170 TRACE_EVENT_BEGIN2("sync", "ReadTransaction",
1171 "src_file", from_here_.file_name(),
1172 "src_func", from_here_.function_name());
1174 Lock(); 1173 Lock();
1175 } 1174 }
1176 1175
1177 ReadTransaction::~ReadTransaction() { 1176 ReadTransaction::~ReadTransaction() {
1178 Unlock(); 1177 Unlock();
1178 TRACE_EVENT_END0("sync", "ReadTransaction");
1179 } 1179 }
1180 1180
1181 WriteTransaction::WriteTransaction(const tracked_objects::Location& location, 1181 WriteTransaction::WriteTransaction(const tracked_objects::Location& location,
1182 WriterTag writer, Directory* directory) 1182 WriterTag writer, Directory* directory)
1183 : BaseTransaction(location, "Write", writer, directory) { 1183 : BaseTransaction(location, "Write", writer, directory) {
1184 TRACE_EVENT_BEGIN2("sync", "WriteTransaction",
1185 "src_file", from_here_.file_name(),
1186 "src_func", from_here_.function_name());
1184 Lock(); 1187 Lock();
1185 } 1188 }
1186 1189
1187 WriteTransaction::WriteTransaction(const tracked_objects::Location& location, 1190 WriteTransaction::WriteTransaction(const tracked_objects::Location& location,
1188 WriterTag writer, 1191 WriterTag writer,
1189 const ScopedDirLookup& scoped_dir) 1192 const ScopedDirLookup& scoped_dir)
1190 : BaseTransaction(location, "Write", writer, scoped_dir.operator->()) { 1193 : BaseTransaction(location, "Write", writer, scoped_dir.operator->()) {
1194 TRACE_EVENT_BEGIN2("sync", "WriteTransaction",
1195 "src_file", from_here_.file_name(),
1196 "src_func", from_here_.function_name());
1191 Lock(); 1197 Lock();
1192 } 1198 }
1193 1199
1194 void WriteTransaction::SaveOriginal(const EntryKernel* entry) { 1200 void WriteTransaction::SaveOriginal(const EntryKernel* entry) {
1195 if (!entry) { 1201 if (!entry) {
1196 return; 1202 return;
1197 } 1203 }
1198 // Insert only if it's not already there. 1204 // Insert only if it's not already there.
1199 const int64 handle = entry->ref(META_HANDLE); 1205 const int64 handle = entry->ref(META_HANDLE);
1200 EntryKernelMutationMap::iterator it = mutations_.lower_bound(handle); 1206 EntryKernelMutationMap::iterator it = mutations_.lower_bound(handle);
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1284 1290
1285 if (OFF != kInvariantCheckLevel) { 1291 if (OFF != kInvariantCheckLevel) {
1286 const bool full_scan = (FULL_DB_VERIFICATION == kInvariantCheckLevel); 1292 const bool full_scan = (FULL_DB_VERIFICATION == kInvariantCheckLevel);
1287 if (full_scan) 1293 if (full_scan)
1288 directory()->CheckTreeInvariants(this, full_scan); 1294 directory()->CheckTreeInvariants(this, full_scan);
1289 else 1295 else
1290 directory()->CheckTreeInvariants(this, mutations.Get()); 1296 directory()->CheckTreeInvariants(this, mutations.Get());
1291 } 1297 }
1292 1298
1293 UnlockAndNotify(mutations); 1299 UnlockAndNotify(mutations);
1300 TRACE_EVENT_END0("sync", "WriteTransaction");
1294 } 1301 }
1295 1302
1296 /////////////////////////////////////////////////////////////////////////// 1303 ///////////////////////////////////////////////////////////////////////////
1297 // Entry 1304 // Entry
1298 1305
1299 Entry::Entry(BaseTransaction* trans, GetById, const Id& id) 1306 Entry::Entry(BaseTransaction* trans, GetById, const Id& id)
1300 : basetrans_(trans) { 1307 : basetrans_(trans) {
1301 kernel_ = trans->directory()->GetEntryById(id); 1308 kernel_ = trans->directory()->GetEntryById(id);
1302 } 1309 }
1303 1310
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
2019 if (entry->ref(NEXT_ID).IsRoot() || 2026 if (entry->ref(NEXT_ID).IsRoot() ||
2020 entry->ref(NEXT_ID) != entry->ref(PREV_ID)) { 2027 entry->ref(NEXT_ID) != entry->ref(PREV_ID)) {
2021 return entry; 2028 return entry;
2022 } 2029 }
2023 } 2030 }
2024 // There were no children in the linked list. 2031 // There were no children in the linked list.
2025 return NULL; 2032 return NULL;
2026 } 2033 }
2027 2034
2028 } // namespace syncable 2035 } // namespace syncable
OLDNEW
« chrome/browser/sync/syncable/model_type.h ('K') | « chrome/browser/sync/syncable/syncable.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698