1/* 2 * Copyright (C) 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17syntax = "proto2"; 18option optimize_for = LITE_RUNTIME; 19 20package perfetto.protos; 21 22// Statistics for the internals of the tracing service. 23// 24// Next id: 10. 25message TraceStats { 26 // From TraceBuffer::Stats. 27 // 28 // Next id: 19. 29 message BufferStats { 30 // Size of the circular buffer in bytes. 31 optional uint64 buffer_size = 12; 32 33 // Num. bytes written into the circular buffer, including chunk headers. 34 optional uint64 bytes_written = 1; 35 36 // Num. bytes overwritten before they have been read (i.e. loss of data). 37 optional uint64 bytes_overwritten = 13; 38 39 // Total size of chunks that were fully read from the circular buffer by the 40 // consumer. This may not be equal to |bytes_written| either in the middle 41 // of tracing, or if |chunks_overwritten| is non-zero. Note that this is the 42 // size of the chunks read from the buffer, including chunk headers, which 43 // will be different from the total size of packets returned to the 44 // consumer. 45 // 46 // The current utilization of the trace buffer (mid-tracing) can be obtained 47 // by subtracting |bytes_read| and |bytes_overwritten| from |bytes_written|, 48 // adding the difference of |padding_bytes_written| and 49 // |padding_bytes_cleared|, and comparing this sum to the |buffer_size|. 50 // Note that this represents the total size of buffered data in the buffer, 51 // yet this data may be spread non-contiguously through the buffer and may 52 // be overridden before the utilization reaches 100%. 53 optional uint64 bytes_read = 14; 54 55 // Num. bytes that were allocated as padding between chunks in the circular 56 // buffer. 57 optional uint64 padding_bytes_written = 15; 58 59 // Num. of padding bytes that were removed from the circular buffer when 60 // they were overwritten. 61 // 62 // The difference between |padding_bytes_written| and 63 // |padding_bytes_cleared| denotes the total size of padding currently 64 // present in the buffer. 65 optional uint64 padding_bytes_cleared = 16; 66 67 // Num. chunks (!= packets) written into the buffer. 68 optional uint64 chunks_written = 2; 69 70 // Num. chunks (!= packets) rewritten into the buffer. This means we rewrote 71 // the same chunk with additional packets appended to the end. 72 optional uint64 chunks_rewritten = 10; 73 74 // Num. chunks overwritten before they have been read (i.e. loss of data). 75 optional uint64 chunks_overwritten = 3; 76 77 // Num. chunks discarded (i.e. loss of data). Can be > 0 only when a buffer 78 // is configured with FillPolicy == DISCARD. 79 optional uint64 chunks_discarded = 18; 80 81 // Num. chunks (!= packets) that were fully read from the circular buffer by 82 // the consumer. This may not be equal to |chunks_written| either in the 83 // middle of tracing, or if |chunks_overwritten| is non-zero. 84 optional uint64 chunks_read = 17; 85 86 // Num. chunks that were committed out of order. 87 optional uint64 chunks_committed_out_of_order = 11; 88 89 // Num. times the ring buffer wrapped around. 90 optional uint64 write_wrap_count = 4; 91 92 // Num. out-of-band (OOB) patches that succeeded. 93 optional uint64 patches_succeeded = 5; 94 95 // Num. OOB patches that failed (e.g., the chunk to patch was gone). 96 optional uint64 patches_failed = 6; 97 98 // Num. readaheads (for large multi-chunk packet reads) that ended up in a 99 // successful packet read. 100 optional uint64 readaheads_succeeded = 7; 101 102 // Num. readaheads aborted because of missing chunks in the sequence stream. 103 // Note that a small number > 0 is totally expected: occasionally, when 104 // issuing a read, the very last packet in a sequence might be incomplete 105 // (because the producer is still writing it while we read). The read will 106 // stop at that point, for that sequence, increasing this counter. 107 optional uint64 readaheads_failed = 8; 108 109 // Num. of violations of the SharedMemoryABI found while writing or reading 110 // the buffer. This is an indication of either a bug in the producer(s) or 111 // malicious producer(s). 112 optional uint64 abi_violations = 9; 113 } 114 115 // Stats for the TraceBuffer(s) of the current trace session. 116 repeated BufferStats buffer_stats = 1; 117 118 // Num. producers connected (whether they are involved in the current tracing 119 // session or not). 120 optional uint32 producers_connected = 2; 121 122 // Num. producers ever seen for all trace sessions since startup (it's a good 123 // proxy for inferring num. producers crashed / killed). 124 optional uint64 producers_seen = 3; 125 126 // Num. data sources registered for all trace sessions. 127 optional uint32 data_sources_registered = 4; 128 129 // Num. data sources ever seen for all trace sessions since startup. 130 optional uint64 data_sources_seen = 5; 131 132 // Num. concurrently active tracing sessions. 133 optional uint32 tracing_sessions = 6; 134 135 // Num. buffers for all tracing session (not just the current one). This will 136 // be >= buffer_stats.size(), because the latter is only about the current 137 // session. 138 optional uint32 total_buffers = 7; 139 140 // The fields below have been introduced in Android Q. 141 142 // Num. chunks that were discarded by the service before attempting to commit 143 // them to a buffer, e.g. because the producer specified an invalid buffer ID. 144 optional uint64 chunks_discarded = 8; 145 146 // Num. patches that were discarded by the service before attempting to apply 147 // them to a buffer, e.g. because the producer specified an invalid buffer ID. 148 optional uint64 patches_discarded = 9; 149} 150