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"; 18 19package perfetto.protos; 20 21// Statistics for the internals of the tracing service. 22// 23// Next id: 17. 24message TraceStats { 25 // From TraceBuffer::Stats. 26 // 27 // Next id: 20. 28 message BufferStats { 29 // Size of the circular buffer in bytes. 30 optional uint64 buffer_size = 12; 31 32 // Num. bytes written into the circular buffer, including chunk headers. 33 optional uint64 bytes_written = 1; 34 35 // Num. bytes overwritten before they have been read (i.e. loss of data). 36 optional uint64 bytes_overwritten = 13; 37 38 // Total size of chunks that were fully read from the circular buffer by the 39 // consumer. This may not be equal to |bytes_written| either in the middle 40 // of tracing, or if |chunks_overwritten| is non-zero. Note that this is the 41 // size of the chunks read from the buffer, including chunk headers, which 42 // will be different from the total size of packets returned to the 43 // consumer. 44 // 45 // The current utilization of the trace buffer (mid-tracing) can be obtained 46 // by subtracting |bytes_read| and |bytes_overwritten| from |bytes_written|, 47 // adding the difference of |padding_bytes_written| and 48 // |padding_bytes_cleared|, and comparing this sum to the |buffer_size|. 49 // Note that this represents the total size of buffered data in the buffer, 50 // yet this data may be spread non-contiguously through the buffer and may 51 // be overridden before the utilization reaches 100%. 52 optional uint64 bytes_read = 14; 53 54 // Num. bytes that were allocated as padding between chunks in the circular 55 // buffer. 56 optional uint64 padding_bytes_written = 15; 57 58 // Num. of padding bytes that were removed from the circular buffer when 59 // they were overwritten. 60 // 61 // The difference between |padding_bytes_written| and 62 // |padding_bytes_cleared| denotes the total size of padding currently 63 // present in the buffer. 64 optional uint64 padding_bytes_cleared = 16; 65 66 // Num. chunks (!= packets) written into the buffer. 67 optional uint64 chunks_written = 2; 68 69 // Num. chunks (!= packets) rewritten into the buffer. This means we rewrote 70 // the same chunk with additional packets appended to the end. 71 optional uint64 chunks_rewritten = 10; 72 73 // Num. chunks overwritten before they have been read (i.e. loss of data). 74 optional uint64 chunks_overwritten = 3; 75 76 // Num. chunks discarded (i.e. loss of data). Can be > 0 only when a buffer 77 // is configured with FillPolicy == DISCARD. 78 optional uint64 chunks_discarded = 18; 79 80 // Num. chunks (!= packets) that were fully read from the circular buffer by 81 // the consumer. This may not be equal to |chunks_written| either in the 82 // middle of tracing, or if |chunks_overwritten| is non-zero. 83 optional uint64 chunks_read = 17; 84 85 // Num. chunks that were committed out of order. 86 optional uint64 chunks_committed_out_of_order = 11; 87 88 // Num. times the ring buffer wrapped around. 89 optional uint64 write_wrap_count = 4; 90 91 // Num. out-of-band (OOB) patches that succeeded. 92 optional uint64 patches_succeeded = 5; 93 94 // Num. OOB patches that failed (e.g., the chunk to patch was gone). 95 optional uint64 patches_failed = 6; 96 97 // Num. readaheads (for large multi-chunk packet reads) that ended up in a 98 // successful packet read. 99 optional uint64 readaheads_succeeded = 7; 100 101 // Num. readaheads aborted because of missing chunks in the sequence stream. 102 // Note that a small number > 0 is totally expected: occasionally, when 103 // issuing a read, the very last packet in a sequence might be incomplete 104 // (because the producer is still writing it while we read). The read will 105 // stop at that point, for that sequence, increasing this counter. 106 optional uint64 readaheads_failed = 8; 107 108 // Num. of violations of the SharedMemoryABI found while writing or reading 109 // the buffer. This is an indication of either a bug in the producer(s) or 110 // malicious producer(s). 111 optional uint64 abi_violations = 9; 112 113 // The fields below have been introduced in Android R. 114 115 // Num. of times the service detected packet loss on a trace writer 116 // sequence. This is usually caused by exhaustion of available chunks in the 117 // writer process's SMB. Note that this relies on the client's TraceWriter 118 // indicating this loss to the service -- packets lost for other reasons are 119 // not reflected in this stat. 120 optional uint64 trace_writer_packet_loss = 19; 121 } 122 123 // Stats for the TraceBuffer(s) of the current trace session. 124 repeated BufferStats buffer_stats = 1; 125 126 // Per TraceWriter stat. Each {producer, trace writer} tuple is publicly 127 // visible as a unique sequence ID in the trace. 128 message WriterStats { 129 // This matches the TracePacket.trusted_packet_sequence_id and is used to 130 // correlate the stats with the actual packet types. 131 optional uint64 sequence_id = 1; 132 133 // These two arrays have the same cardinality and match the cardinality of 134 // chunk_payload_histogram_def + 1 (for the overflow bucket, see below). 135 // `sum` contains the SUM(entries) and `counts` contains the COUNT(entries) 136 // for each bucket. 137 repeated uint64 chunk_payload_histogram_counts = 2 [packed = true]; 138 repeated int64 chunk_payload_histogram_sum = 3 [packed = true]; 139 } 140 141 // The thresholds of each the `writer_stats` histogram buckets. This is 142 // emitted only once as all WriterStats share the same bucket layout. 143 // This field has the same cardinality of the 144 // `writer_stats.chunk_payload_histogram_{counts,sum}` - 1. 145 // (The -1 is because the last overflow bucket is not reported in the _def). 146 // An array of values [10, 100, 1000] in the _def array means that there are 147 // four buckets (3 + the implicit overflow bucket): 148 // [0]: x <= 10; [1]: 100 < x <= 1000; [2]: 1000 < x <= 1000; [3]: x > 1000. 149 repeated int64 chunk_payload_histogram_def = 17; 150 repeated WriterStats writer_stats = 18; 151 152 // Num. producers connected (whether they are involved in the current tracing 153 // session or not). 154 optional uint32 producers_connected = 2; 155 156 // Num. producers ever seen for all trace sessions since startup (it's a good 157 // proxy for inferring num. producers crashed / killed). 158 optional uint64 producers_seen = 3; 159 160 // Num. data sources registered for all trace sessions. 161 optional uint32 data_sources_registered = 4; 162 163 // Num. data sources ever seen for all trace sessions since startup. 164 optional uint64 data_sources_seen = 5; 165 166 // Num. concurrently active tracing sessions. 167 optional uint32 tracing_sessions = 6; 168 169 // Num. buffers for all tracing session (not just the current one). This will 170 // be >= buffer_stats.size(), because the latter is only about the current 171 // session. 172 optional uint32 total_buffers = 7; 173 174 // The fields below have been introduced in Android Q. 175 176 // Num. chunks that were discarded by the service before attempting to commit 177 // them to a buffer, e.g. because the producer specified an invalid buffer ID. 178 optional uint64 chunks_discarded = 8; 179 180 // Num. patches that were discarded by the service before attempting to apply 181 // them to a buffer, e.g. because the producer specified an invalid buffer ID. 182 optional uint64 patches_discarded = 9; 183 184 // Packets that failed validation of the TrustedPacket. If this is > 0, there 185 // is a bug in the producer. 186 optional uint64 invalid_packets = 10; 187 188 // This is set only when the TraceConfig specifies a TraceFilter. 189 message FilterStats { 190 optional uint64 input_packets = 1; 191 optional uint64 input_bytes = 2; 192 optional uint64 output_bytes = 3; 193 optional uint64 errors = 4; 194 optional uint64 time_taken_ns = 5; 195 } 196 optional FilterStats filter_stats = 11; 197 198 // Count of Flush() requests (either from the Consumer, or self-induced 199 // periodic flushes). The final Flush() is also included in the count. 200 optional uint64 flushes_requested = 12; 201 202 // The count of the Flush() requests that were completed successfully. 203 // In a well behaving trace this should always be == `flush_requests`. 204 optional uint64 flushes_succeeded = 13; 205 206 // The count of the Flush() requests that failed (in most timed out). 207 // In a well behaving trace this should always be == 0. 208 optional uint64 flushes_failed = 14; 209 210 enum FinalFlushOutcome { 211 FINAL_FLUSH_UNSPECIFIED = 0; 212 FINAL_FLUSH_SUCCEEDED = 1; 213 FINAL_FLUSH_FAILED = 2; 214 } 215 optional FinalFlushOutcome final_flush_outcome = 15; 216} 217