/* * Copyright (C) 2023 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_SORTER_TRACE_TOKEN_BUFFER_H_ #define SRC_TRACE_PROCESSOR_SORTER_TRACE_TOKEN_BUFFER_H_ #include <cstdint> #include <limits> #include <optional> #include <utility> #include <vector> #include "perfetto/base/compiler.h" #include "perfetto/ext/base/circular_queue.h" #include "perfetto/ext/base/utils.h" #include "perfetto/trace_processor/trace_blob.h" #include "perfetto/trace_processor/trace_blob_view.h" #include "src/trace_processor/importers/common/parser_types.h" #include "src/trace_processor/util/bump_allocator.h" namespace perfetto { namespace trace_processor { // Helper class which stores tokenized objects while the corresponding events // are being sorted by TraceSorter. // // This class intrusively compresses the tokenized objects as much as possible // to reduce their memory footprint. This is important to reduce the peak memory // usage of TraceProcessor which is always hit at some point during sorting. // The tokenized objects make up the vast majority of this peak so we trade the // complexity in this class for big reductions in the peak use. // // go/perfetto-tp-memory-use gives an overview of trace processor memory usage. class TraceTokenBuffer { … }; // GCC7 does not like us declaring these inside the class so define these // out-of-line. template <> PERFETTO_WARN_UNUSED_RESULT TrackEventData TraceTokenBuffer::Extract<TrackEventData>(Id); template <> PERFETTO_WARN_UNUSED_RESULT inline TracePacketData TraceTokenBuffer::Extract<TracePacketData>(Id id) { … } } // namespace trace_processor } // namespace perfetto #endif // SRC_TRACE_PROCESSOR_SORTER_TRACE_TOKEN_BUFFER_H_