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

Unified Diff: third_party/WebKit/Source/devtools/front_end/sdk/TracingModel.js

Issue 2746153005: DevTools: move flow events tracking to TracingModel, support cross-threads case (Closed)
Patch Set: fixed infinite chains of flow events Created 3 years, 9 months 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
Index: third_party/WebKit/Source/devtools/front_end/sdk/TracingModel.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/TracingModel.js b/third_party/WebKit/Source/devtools/front_end/sdk/TracingModel.js
index 996fc50311f94ae9feac104e0ecd159c9af2f65d..19949d4fd7355281dea85871a7403544f2384afb 100644
--- a/third_party/WebKit/Source/devtools/front_end/sdk/TracingModel.js
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/TracingModel.js
@@ -118,6 +118,13 @@ SDK.TracingModel = class {
}
/**
+ * @return {!Array.<!SDK.TracingModel.Event>}
+ */
+ flowHeads() {
+ return this._flowHeads;
+ }
+
+ /**
* @param {!Array.<!SDK.TracingManager.EventPayload>} events
*/
setEventsForTest(events) {
@@ -136,6 +143,7 @@ SDK.TracingModel = class {
tracingComplete() {
this._processPendingAsyncEvents();
+ this._processFlowEvents();
this._backingStorage.appendString(this._firstWritePending ? '[]' : ']');
this._backingStorage.finishWriting();
this._firstWritePending = false;
@@ -162,10 +170,14 @@ SDK.TracingModel = class {
this._openAsyncEvents = new Map();
/** @type {!Map<string, !Array<!SDK.TracingModel.AsyncEvent>>} */
this._openNestableAsyncEvents = new Map();
+ /** @type {!Map<string, !Array<!SDK.TracingModel.Event>>} */
+ this._flowEventsById = new Map();
/** @type {!Map<string, !SDK.TracingModel.ProfileEventsGroup>} */
this._profileGroups = new Map();
/** @type {!Map<string, !Set<string>>} */
this._parsedCategories = new Map();
+ /** @type {!Array<!SDK.TracingModel.Event>} */
+ this._flowHeads = [];
}
/**
@@ -231,8 +243,18 @@ SDK.TracingModel = class {
// Build async event when we've got events from all threads & processes, so we can sort them and process in the
// chronological order. However, also add individual async events to the thread flow (above), so we can easily
// display them on the same chart as other events, should we choose so.
- if (SDK.TracingModel.isAsyncPhase(payload.ph))
+ if (SDK.TracingModel.isAsyncPhase(payload.ph)) {
this._asyncEvents.push(event);
+ } else if (SDK.TracingModel.isFlowPhase(payload.ph)) {
+ var key = `${event.categoriesString}-${event.name}-${event.id}`;
pfeldman 2017/03/16 07:03:50 I don't think categoriesString and event name shou
+ var flowEvents = this._flowEventsById.get(key);
+ if (!flowEvents) {
+ flowEvents = [];
+ this._flowEventsById.set(key, flowEvents);
+ }
+ flowEvents.push(event);
+ }
+
event._setBackingStorage(backingStorage);
if (event.hasCategory(SDK.TracingModel.DevToolsMetadataEventCategory))
this._devToolsMetadataEvents.push(event);
@@ -329,6 +351,22 @@ SDK.TracingModel = class {
this._closeOpenAsyncEvents();
}
+ _processFlowEvents() {
+ var phases = SDK.TracingModel.Phase;
+ for (var events of this._flowEventsById.values()) {
+ events.stableSort(SDK.TracingModel.Event.compareStartTime);
+ var lastInChain = null;
+ for (var e of events) {
+ if (lastInChain && e.phase !== phases.FlowBegin)
+ lastInChain._appendFlowEvent(e);
+ if (!lastInChain && e.phase !== phases.FlowEnd)
+ this._flowHeads.push(e);
pfeldman 2017/03/16 02:00:22 So if there is no begin, you still consider it a h
+ lastInChain = e.phase !== phases.FlowEnd ? e : null;
pfeldman 2017/03/16 02:00:22 why do you need all this logic? it is either begin
+ }
+ }
+ this._flowEventsById.clear();
+ }
+
_closeOpenAsyncEvents() {
for (var event of this._openAsyncEvents.values()) {
event.setEndTime(this._maximumRecordTime);
@@ -525,6 +563,10 @@ SDK.TracingModel.Event = class {
this.thread = thread;
/** @type {!Object} */
this.args = {};
+ /** @type {!SDK.TracingModel.Event|undefined} */
+ this.nextFlow;
+ /** @type {!SDK.TracingModel.Event|undefined} */
+ this.previousFlow;
/** @type {number} */
this.selfTime = 0;
@@ -628,6 +670,14 @@ SDK.TracingModel.Event = class {
}
/**
+ * @param {!SDK.TracingModel.Event} nextFlow
+ */
+ _appendFlowEvent(nextFlow) {
+ this.nextFlow = nextFlow;
+ nextFlow.previousFlow = this;
+ }
+
+ /**
* @param {?function():!Promise.<?string>} backingStorage
*/
_setBackingStorage(backingStorage) {

Powered by Google App Engine
This is Rietveld 408576698