/* * Copyright (C) 2020 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef SRC_TRACE_PROCESSOR_IMPORTERS_COMMON_ASYNC_TRACK_SET_TRACKER_H_ #define SRC_TRACE_PROCESSOR_IMPORTERS_COMMON_ASYNC_TRACK_SET_TRACKER_H_ #include "src/trace_processor/storage/trace_storage.h" namespace perfetto { namespace trace_processor { class TraceProcessorContext; class AsyncTrackSetTrackerUnittest; // Tracker used to reduce the number of trace processor tracks corresponding // to a single "UI track". // // UIs using trace processor want to display all slices in the same context // (e.g. same upid) and same name into a single track. However, because trace // processor does not allow parallel slices on a single track (because it breaks // things like span join, self time computation etc.), at the trace processor // level these parallel slices are put on different tracks. // // Creating a new track for every event, however, leads to an explosion of // tracks which is undesirable. This class exists to multiplex slices so that // n events correspond to a single track in a way which minimises the number of // tracks which needs to be merged by the UI. // // The intended usage of this class is for callers to first call one of the // Intern* methods to obtain a TrackSetId followed by Begin/End just before // calling into SliceTracker's Begin/End respectively. For example: // TrackSetId set_id = track_set_tracker->InternProcessTrackSet(upid, name); // if (event.begin) { // TrackId id = track_set_tracker->Begin(set_id, cookie); // slice_tracker->Begin(ts, id, ...) // } else { // ... (same thing with end) // } // Alternatively, instead of Begin/End, Scoped can also be called if supported // by the track type. class AsyncTrackSetTracker { … }; } // namespace trace_processor } // namespace perfetto #endif // SRC_TRACE_PROCESSOR_IMPORTERS_COMMON_ASYNC_TRACK_SET_TRACKER_H_