tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

ProfileBufferEntryKinds.h (4572B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef ProfileBufferEntryKinds_h
      8 #define ProfileBufferEntryKinds_h
      9 
     10 #include "mozilla/BaseProfilerUtils.h"
     11 
     12 #include <cstdint>
     13 
     14 namespace mozilla {
     15 
     16 // This is equal to sizeof(double), which is the largest non-char variant in
     17 // |u|.
     18 static constexpr size_t ProfileBufferEntryNumChars = 8;
     19 
     20 // NOTE!  If you add entries, you need to verify if they need to be added to the
     21 // switch statement in DuplicateLastSample!
     22 // This will evaluate the MACRO with (KIND, TYPE, SIZE)
     23 #define FOR_EACH_PROFILE_BUFFER_ENTRY_KIND(MACRO)                 \
     24  MACRO(CategoryPair, int, sizeof(int))                           \
     25  MACRO(CollectionStart, double, sizeof(double))                  \
     26  MACRO(CollectionEnd, double, sizeof(double))                    \
     27  MACRO(Label, const char*, sizeof(const char*))                  \
     28  MACRO(FrameFlags, uint64_t, sizeof(uint64_t))                   \
     29  MACRO(DynamicStringFragment, char*, ProfileBufferEntryNumChars) \
     30  MACRO(JitReturnAddr, void*, sizeof(void*))                      \
     31  MACRO(InnerWindowID, uint64_t, sizeof(uint64_t))                \
     32  MACRO(SourceId, uint32_t, sizeof(uint32_t))                     \
     33  MACRO(LineNumber, int, sizeof(int))                             \
     34  MACRO(ColumnNumber, int, sizeof(int))                           \
     35  MACRO(NativeLeafAddr, void*, sizeof(void*))                     \
     36  MACRO(Pause, double, sizeof(double))                            \
     37  MACRO(Resume, double, sizeof(double))                           \
     38  MACRO(PauseSampling, double, sizeof(double))                    \
     39  MACRO(ResumeSampling, double, sizeof(double))                   \
     40  MACRO(Responsiveness, double, sizeof(double))                   \
     41  MACRO(ThreadId, ::mozilla::baseprofiler::BaseProfilerThreadId,  \
     42        sizeof(::mozilla::baseprofiler::BaseProfilerThreadId))    \
     43  MACRO(Time, double, sizeof(double))                             \
     44  MACRO(TimeBeforeCompactStack, double, sizeof(double))           \
     45  MACRO(TimeBeforeSameSample, double, sizeof(double))             \
     46  MACRO(CounterId, void*, sizeof(void*))                          \
     47  MACRO(Number, uint64_t, sizeof(uint64_t))                       \
     48  MACRO(Count, int64_t, sizeof(int64_t))                          \
     49  MACRO(ProfilerOverheadTime, double, sizeof(double))             \
     50  MACRO(ProfilerOverheadDuration, double, sizeof(double))
     51 
     52 // The `Kind` is a single byte identifying the type of data that is actually
     53 // stored in a `ProfileBufferEntry`, as per the list in
     54 // `FOR_EACH_PROFILE_BUFFER_ENTRY_KIND`.
     55 //
     56 // This byte is also used to identify entries in ProfileChunkedBuffer blocks,
     57 // for both "legacy" entries that do contain a `ProfileBufferEntry`, and for
     58 // new types of entries that may carry more data of different types.
     59 // TODO: Eventually each type of "legacy" entry should be replaced with newer,
     60 // more efficient kinds of entries (e.g., stack frames could be stored in one
     61 // bigger entry, instead of multiple `ProfileBufferEntry`s); then we could
     62 // discard `ProfileBufferEntry` and move this enum to a more appropriate spot.
     63 enum class ProfileBufferEntryKind : uint8_t {
     64  INVALID = 0,
     65 #define KIND(KIND, TYPE, SIZE) KIND,
     66  FOR_EACH_PROFILE_BUFFER_ENTRY_KIND(KIND)
     67 #undef KIND
     68 
     69  // Any value under `LEGACY_LIMIT` represents a `ProfileBufferEntry`.
     70  LEGACY_LIMIT,
     71 
     72  // Any value starting here does *not* represent a `ProfileBufferEntry` and
     73  // requires separate decoding and handling.
     74 
     75  // Markers and their data.
     76  Marker = LEGACY_LIMIT,
     77 
     78  // Entry with "running times", such as CPU usage measurements.
     79  // Optional between TimeBeforeX and X.
     80  RunningTimes,
     81 
     82  // Optional between TimeBeforeX and X.
     83  UnresponsiveDurationMs,
     84 
     85  // Collection of legacy stack entries, must follow a ThreadId and
     86  // TimeBeforeCompactStack (which are not included in the CompactStack;
     87  // TimeBeforeCompactStack is equivalent to Time, but indicates that a
     88  // CompactStack follows shortly afterwards).
     89  CompactStack,
     90 
     91  // Indicates that this sample is identical to the previous one, must follow a
     92  // ThreadId and TimeBeforeSameSample.
     93  SameSample,
     94 
     95  MODERN_LIMIT
     96 };
     97 
     98 enum class MarkerPayloadType : uint8_t {
     99  Cpp,
    100  Rust,
    101 };
    102 
    103 }  // namespace mozilla
    104 
    105 #endif  // ProfileBufferEntryKinds_h