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

Unified Diff: base/debug/trace_event_impl.cc

Issue 804083004: Revert of DevTools: Parallelize trace messages serialization. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/debug/trace_event_impl.h ('k') | content/browser/tracing/tracing_controller_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug/trace_event_impl.cc
diff --git a/base/debug/trace_event_impl.cc b/base/debug/trace_event_impl.cc
index 47baf0b69156a9b2e0ee9d63d6b8888a265c5dfb..45912865b1511c8b39ee31df8fe6cf5374331106 100644
--- a/base/debug/trace_event_impl.cc
+++ b/base/debug/trace_event_impl.cc
@@ -32,7 +32,6 @@
#include "base/third_party/dynamic_annotations/dynamic_annotations.h"
#include "base/threading/platform_thread.h"
#include "base/threading/thread_id_name_manager.h"
-#include "base/threading/worker_pool.h"
#include "base/time/time.h"
#if defined(OS_WIN)
@@ -74,7 +73,7 @@
512000000 / kTraceBufferChunkSize;
const size_t kTraceEventVectorBufferChunks = 256000 / kTraceBufferChunkSize;
const size_t kTraceEventRingBufferChunks = kTraceEventVectorBufferChunks / 4;
-const size_t kTraceEventBufferSizeInBytes = 10 * 1024 * 1024;
+const size_t kTraceEventBatchChunks = 1000 / kTraceBufferChunkSize;
// Can store results for 30 seconds with 1 ms sampling interval.
const size_t kMonitorTraceEventBufferChunks = 30000 / kTraceBufferChunkSize;
// ECHO_TO_CONSOLE needs a small buffer to hold the unfinished COMPLETE events.
@@ -1212,8 +1211,7 @@
event_callback_category_filter_(
CategoryFilter::kDefaultCategoryFilterString),
thread_shared_chunk_index_(0),
- generation_(0),
- use_worker_thread_(false) {
+ generation_(0) {
// Trace is enabled or disabled on one thread while other threads are
// accessing the enabled flag. We don't care whether edge-case events are
// traced or not, so we allow races on the enabled flag to keep the trace
@@ -1686,9 +1684,7 @@
// - The message loop will be removed from thread_message_loops_;
// If this is the last message loop, finish the flush;
// 4. If any thread hasn't finish its flush in time, finish the flush.
-void TraceLog::Flush(const TraceLog::OutputCallback& cb,
- bool use_worker_thread) {
- use_worker_thread_ = use_worker_thread;
+void TraceLog::Flush(const TraceLog::OutputCallback& cb) {
if (IsEnabled()) {
// Can't flush when tracing is enabled because otherwise PostTask would
// - generate more trace events;
@@ -1742,7 +1738,6 @@
FinishFlush(generation);
}
-// Usually it runs on a different thread.
void TraceLog::ConvertTraceEventsToTraceFormat(
scoped_ptr<TraceBuffer> logged_events,
const TraceLog::OutputCallback& flush_output_callback) {
@@ -1757,17 +1752,19 @@
scoped_refptr<RefCountedString> json_events_str_ptr =
new RefCountedString();
- while (json_events_str_ptr->size() < kTraceEventBufferSizeInBytes) {
+ for (size_t i = 0; i < kTraceEventBatchChunks; ++i) {
const TraceBufferChunk* chunk = logged_events->NextChunk();
- has_more_events = chunk != NULL;
- if (!chunk)
+ if (!chunk) {
+ has_more_events = false;
break;
+ }
for (size_t j = 0; j < chunk->size(); ++j) {
- if (json_events_str_ptr->size())
+ if (i > 0 || j > 0)
json_events_str_ptr->data().append(",");
chunk->GetEventAt(j)->AppendAsJSON(&(json_events_str_ptr->data()));
}
}
+
flush_output_callback.Run(json_events_str_ptr, has_more_events);
} while (has_more_events);
}
@@ -1789,16 +1786,6 @@
flush_message_loop_proxy_ = NULL;
flush_output_callback = flush_output_callback_;
flush_output_callback_.Reset();
- }
-
- if (use_worker_thread_ &&
- WorkerPool::PostTask(
- FROM_HERE,
- Bind(&TraceLog::ConvertTraceEventsToTraceFormat,
- Passed(&previous_logged_events),
- flush_output_callback),
- true)) {
- return;
}
ConvertTraceEventsToTraceFormat(previous_logged_events.Pass(),
« no previous file with comments | « base/debug/trace_event_impl.h ('k') | content/browser/tracing/tracing_controller_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698