• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2018 Google Inc. All Rights Reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//   http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15syntax = "proto2";
16
17package soong_build_metrics;
18option go_package = "android/soong/ui/metrics/metrics_proto";
19
20message MetricsBase {
21  // Timestamp generated when the build starts.
22  optional int64 build_date_timestamp = 1;
23
24  // It is usually used to specify the branch name [and release candidate].
25  optional string build_id  = 2;
26
27  // The platform version codename, eg. P, Q, REL.
28  optional string platform_version_codename = 3;
29
30  // The target product information, eg. aosp_arm.
31  optional string target_product = 4;
32
33  enum BuildVariant {
34    USER = 0;
35    USERDEBUG = 1;
36    ENG = 2;
37  }
38  // The target build variant information, eg. eng.
39  optional BuildVariant target_build_variant = 5 [default = ENG];
40
41  enum Arch {
42    UNKNOWN = 0;
43    ARM = 1;
44    ARM64 = 2;
45    X86 = 3;
46    X86_64 = 4;
47  }
48  // The target arch information, eg. arm.
49  optional Arch target_arch = 6 [default = UNKNOWN];
50
51  // The target arch variant information, eg. armv7-a-neon.
52  optional string target_arch_variant = 7;
53
54  // The target cpu variant information, eg. generic.
55  optional string target_cpu_variant = 8;
56
57  // The host arch information, eg. x86_64.
58  optional Arch host_arch = 9 [default = UNKNOWN];
59
60  // The host 2nd arch information, eg. x86.
61  optional Arch host_2nd_arch = 10 [default = UNKNOWN];
62
63  // The host os information, eg. linux.
64  optional string host_os = 11;
65
66  // The host os extra information, eg. Linux-4.17.0-3rodete2-amd64-x86_64-Debian-GNU.
67  optional string host_os_extra = 12;
68
69  // The host cross os information, eg. windows.
70  optional string host_cross_os = 13;
71
72  // The host cross arch information, eg. x86.
73  optional string host_cross_arch = 14;
74
75  // The host cross 2nd arch information, eg. x86_64.
76  optional string host_cross_2nd_arch = 15;
77
78  // The directory for generated built artifacts installation, eg. out.
79  optional string out_dir = 16;
80
81  // The metrics for calling various tools (microfactory) before Soong_UI starts.
82  repeated PerfInfo setup_tools = 17;
83
84  // The metrics for calling Kati by multiple times.
85  repeated PerfInfo kati_runs = 18;
86
87  // The metrics for calling Soong.
88  repeated PerfInfo soong_runs = 19;
89
90  // The metrics for calling Ninja.
91  repeated PerfInfo ninja_runs = 20;
92
93  // The metrics for the whole build
94  optional PerfInfo total = 21;
95
96  // Deprecated because instead of embedding in a MetricsBase, we keep
97  // SoongBuildMetrics in its own file
98  optional SoongBuildMetrics soong_build_metrics = 22 [deprecated=true];
99
100  optional BuildConfig build_config = 23;
101
102  // The hostname of the machine.
103  optional string hostname = 24;
104
105  // The system resource information such as total physical memory.
106  optional SystemResourceInfo system_resource_info = 25;
107
108  // The build command that the user entered to the build system.
109  optional string build_command = 26;
110
111  // The metrics for calling Bazel.
112  repeated PerfInfo bazel_runs = 27;
113
114  // The metrics of the experiment config fetcher
115  optional ExpConfigFetcher exp_config_fetcher = 28;
116
117  // Whether the build exited with a panic or non-zero exit code, includes both
118  // non-zero exits of recorded phases and non-recorded phases of the build.
119  optional bool non_zero_exit = 29;
120
121  // The error message due to a non-zero exit _only_ if it did not occur in a
122  // recorded phase of the build.
123  optional string error_message = 30;
124
125  // The Git Manifest for the user's branch.
126  optional string manifest_url = 31;
127
128  // The branch on which the build occurred.
129  // Example: refs/heads/master
130  optional string branch = 32;
131
132  // The metric of critical path in build
133  optional CriticalPathInfo critical_path_info = 33;
134
135  // Environment variables that have changed value since the previous build,
136  // which were responsible for retriggering build analysis.
137  // Note that not all changed environment variables result in analysis retriggering.
138  // If there was no previous build, this list will be empty.
139  repeated string changed_environment_variable = 34;
140
141  // Metrics related to optimized builds.
142  optional OptimizedBuildMetrics optimized_build_metrics = 35;
143
144  // The target release information. e.g., trunk_staging.
145  optional string target_release = 36;
146}
147
148message BuildConfig {
149  enum NinjaWeightListSource {
150    NOT_USED = 0;
151    NINJA_LOG = 1;
152    EVENLY_DISTRIBUTED = 2;
153    EXTERNAL_FILE = 3;
154    HINT_FROM_SOONG = 4;
155  }
156
157  optional bool use_goma = 1;
158
159  optional bool use_rbe = 2;
160
161  optional bool force_use_goma = 3;
162
163  // Whether the Bazel is acting as the Ninja executor for this build.
164  optional bool bazel_as_ninja = 4;
165
166  // Whether build is occurring in a mixed build mode, where Bazel maintains the
167  // definition and build of some modules in cooperation with Soong.
168  optional bool bazel_mixed_build = 5;
169
170  // These are the targets soong passes to ninja, these targets include special
171  // targets such as droid as well as the regular build targets.
172  repeated string targets = 6;
173
174  // Whether the user explicitly disabled bazel mixed builds for this build.
175  optional bool force_disable_bazel_mixed_build = 7;
176
177  // NOT_USED - ninja doesn't use weight list.
178  // NINJA_LOG - ninja uses weight list based on previous builds by ninja log
179  // EVENLY_DISTRIBUTED - ninja thinks every task has the same weight.
180  // EXTERNAL_FILE - ninja uses an external custom weight list
181  // HINT_FROM_SOONG - ninja uses a prioritized module list from Soong
182  optional NinjaWeightListSource ninja_weight_list_source = 8 [default = NOT_USED];
183
184  // Values of some build-affecting environment variables.
185  optional SoongEnvVars soong_env_vars = 9;
186
187  // Whether this build uses soong-only (no kati) mode (either via environment variable,
188  // command line flag or product config.
189  optional bool soong_only = 10;
190}
191
192message SoongEnvVars {
193  // SOONG_PARTIAL_COMPILE
194  optional string partial_compile = 1;
195
196  // SOONG_USE_PARTIAL_COMPILE
197  optional string use_partial_compile = 2;
198}
199
200message SystemResourceInfo {
201  // The total physical memory in bytes.
202  optional uint64 total_physical_memory = 1;
203
204  // The total of available cores for building
205  optional int32 available_cpus = 2;
206
207  // Information about the machine's CPU(s).
208  optional SystemCpuInfo cpu_info = 3;
209
210  // Information about the machine's memory.
211  optional SystemMemInfo mem_info = 4;
212}
213
214message SystemCpuInfo {
215  // The vendor id
216  optional string vendor_id = 1;
217
218  // The model name
219  optional string model_name = 2;
220
221  // The number of CPU cores
222  optional int32 cpu_cores = 3;
223
224  // The CPU flags
225  optional string flags = 4;
226}
227
228message SystemMemInfo {
229  // The total system memory
230  optional uint64 mem_total = 1;
231
232  // The free system memory
233  optional uint64 mem_free = 2;
234
235  // The available system memory
236  optional uint64 mem_available = 3;
237}
238
239message PerfInfo {
240  // The description for the phase/action/part while the tool running.
241  optional string description = 1;
242
243  // The name for the running phase/action/part.
244  optional string name = 2;
245
246  // The absolute start time.
247  // The number of nanoseconds elapsed since January 1, 1970 UTC.
248  optional uint64 start_time = 3;
249
250  // The real running time.
251  // The number of nanoseconds elapsed since start_time.
252  optional uint64 real_time = 4;
253
254  // The number of MB for memory use (deprecated as it is too generic).
255  optional uint64 memory_use = 5 [deprecated=true];
256
257  // The resource information of each executed process.
258  repeated ProcessResourceInfo processes_resource_info = 6;
259
260  // Whether the phase of tool running exited with a panic or non-zero exit
261  // code.
262  optional bool non_zero_exit = 7;
263
264  // The error message, if any, due to a non-zero exit.
265  optional string error_message = 8;
266}
267
268message PerfCounters {
269  // The timestamp of these counters in nanoseconds.
270  optional uint64 time = 1;
271
272  // A list of counter names and values.
273  repeated PerfCounterGroup groups = 2;
274}
275
276message PerfCounterGroup {
277  // The name of this counter group (e.g. "cpu" or "memory")
278  optional string name = 1;
279
280  // The counters in this group
281  repeated PerfCounter counters = 2;
282}
283
284message PerfCounter {
285  // The name of this counter.
286  optional string name = 1;
287
288  // The value of this counter.
289  optional int64 value = 2;
290}
291
292message ProcessResourceInfo {
293  // The name of the process for identification.
294  optional string name = 1;
295
296  // The amount of time spent executing in user space in microseconds.
297  optional uint64 user_time_micros = 2;
298
299  // The amount of time spent executing in kernel mode in microseconds.
300  optional uint64 system_time_micros = 3;
301
302  // The maximum resident set size memory used in kilobytes.
303  optional uint64 max_rss_kb = 4;
304
305  // The number of minor page faults serviced without any I/O activity.
306  optional uint64 minor_page_faults = 5;
307
308  // The number of major page faults serviced that required I/O activity.
309  optional uint64 major_page_faults = 6;
310
311  // Total IO input in kilobytes.
312  optional uint64 io_input_kb= 7;
313
314  // Total IO output in kilobytes.
315  optional uint64 io_output_kb = 8;
316
317  // The number of voluntary context switches
318  optional uint64 voluntary_context_switches = 9;
319
320  // The number of involuntary context switches
321  optional uint64 involuntary_context_switches = 10;
322}
323
324message ModuleTypeInfo {
325  enum BuildSystem {
326    UNKNOWN = 0;
327    SOONG = 1;
328    MAKE = 2;
329  }
330  // The build system, e.g. Soong or Make.
331  optional BuildSystem build_system = 1 [default = UNKNOWN];
332
333  // The module type, e.g. java_library, cc_binary, and etc.
334  optional string module_type = 2;
335
336  // The number of logical modules.
337  optional uint32 num_of_modules = 3;
338}
339
340message CriticalUserJourneyMetrics {
341  // The name of a critical user journey test.
342  optional string name = 1;
343
344  // The metrics produced when running the critical user journey test.
345  optional MetricsBase metrics = 2;
346}
347
348message CriticalUserJourneysMetrics {
349  // A set of metrics from a run of the critical user journey tests.
350  repeated CriticalUserJourneyMetrics cujs = 1;
351}
352
353message SoongBuildMetrics {
354  // The number of modules handled by soong_build.
355  optional uint32 modules = 1;
356
357  // The total number of variants handled by soong_build.
358  optional uint32 variants = 2;
359
360  // The total number of allocations in soong_build.
361  optional uint64 total_alloc_count = 3;
362
363  // The total size of allocations in soong_build in bytes.
364  optional uint64 total_alloc_size = 4;
365
366  // The approximate maximum size of the heap in soong_build in bytes.
367  optional uint64 max_heap_size = 5;
368
369  // Runtime metrics for soong_build execution.
370  repeated PerfInfo events = 6;
371
372  // Mixed Builds information
373  optional MixedBuildsInfo mixed_builds_info = 7;
374
375  // Performance during for soong_build execution.
376  repeated PerfCounters perf_counters = 8;
377}
378
379message ExpConfigFetcher {
380  enum ConfigStatus {
381    NO_CONFIG = 0;
382    CONFIG = 1;
383    ERROR = 2;
384    MISSING_GCERT = 3;
385  }
386  // The result of the call to expconfigfetcher
387  // NO_CONFIG - Not part of experiment
388  // CONFIG - Part of experiment, config copied successfully
389  // ERROR - expconfigfetcher failed
390  optional ConfigStatus status = 1;
391
392  // The output config filename
393  optional string filename = 2;
394
395  // Time, in microseconds, taken by the expconfigfetcher
396  optional uint64 micros = 3;
397}
398
399message MixedBuildsInfo{
400  // Modules may be listed below as both enabled for Mixed Builds
401  // and disabled for Mixed Builds. This implies that some variants
402  // of the module are handled by Bazel in a Mixed Build, and other
403  // variants of the same module are handled by Soong.
404
405  // Modules that are enabled for Mixed Builds.
406  repeated string mixed_build_enabled_modules = 1;
407
408  // Modules that are not currently eligible to be handled
409  // by Bazel in a Mixed Build.
410  // Note that not all modules exempt from Bazel handling are
411  // listed. This list includes only modules which are of a
412  // Mixed-Build supported module type but are nevertheless not
413  // handled by Bazel. This may occur due to being present in
414  // the mixed build denylist, or as part of an unsupported
415  // mixed build variant type such as Windows.
416
417  // Modules that are not enabled for MixedBuilds
418  repeated string mixed_build_disabled_modules = 2;
419}
420
421// CriticalPathInfo contains critical path nodes's information.
422// A critical path is a path determining the minimum time needed for the whole build given perfect parallelism.
423message CriticalPathInfo {
424  // Real time which the build system spent in microseconds
425  optional uint64 elapsed_time_micros = 1;
426  // The sum of execution time of the longest path from leave to the root in microseconds
427  optional uint64 critical_path_time_micros = 2;
428  // Detailed job information in a critical path.
429  repeated JobInfo critical_path = 4;
430  // Detailed job information for long running jobs (>30 seconds). These may or may not also be on a critical path.
431  repeated JobInfo long_running_jobs = 5;
432}
433
434message JobInfo {
435  // Real time which a job spent in microseconds
436  optional uint64 elapsed_time_micros = 1;
437  // Description of a job
438  optional string job_description = 2;
439}
440
441message OptimizedBuildMetrics {
442  // The total time spent analyzing what/how to optimize everything.
443  optional PerfInfo analysis_perf = 1;
444  // The total time spent packaging artifacts.
445  optional PerfInfo packaging_perf = 2;
446  // Information for a single target (e.g. general-tests).
447  repeated TargetOptimizationResult target_result = 3;
448
449  message TargetOptimizationResult {
450    // Target name (e.g. general-tests).
451    optional string name = 1;
452    // Whether or not this target was optimized.
453    optional bool optimized = 2;
454    // Reasoning for why the target wasn't optimized if it wasn't
455    optional string optimization_rationale = 3;
456    // Time spent packaging this specific target (if it was optimized).
457    optional PerfInfo packaging_perf = 4;
458    // Information for each different artifact produced by this target (if it
459    // was optimized).
460    repeated OutputArtifact output_artifact = 5;
461
462    message OutputArtifact {
463      // Artifact file name (e.g. general-tests.zip)
464      optional string name = 1;
465      // Size of the file.
466      optional int64 size = 2;
467      // Lists of modules packaged into this artifact.
468      repeated string included_modules = 3;
469    }
470  }
471}
472
473// This is created by soong_ui from SoongExexcutionMetrics files.
474message ExecutionMetrics {
475  // The arguments provided on the command line.
476  repeated string command_args = 1;
477
478  // Changed files detected by the build.
479  optional AggregatedFileList changed_files = 2;
480}
481
482// This is created by soong_ui from the various
483// android.find_input_delta_proto.FileList metrics provided to it by
484// find_input_delta.
485message AggregatedFileList {
486  // The (possibly truncated list of) added files.
487  repeated string additions = 2;
488
489  // The (possibly truncated list of) changed files.
490  repeated string changes = 3;
491
492  // The (possibly truncated list of) deleted files.
493  repeated string deletions = 4;
494
495  // Count of files added/changed/deleted.
496  optional uint32 total_delta = 5;
497
498  // Counts by extension.
499  repeated FileCount counts = 6;
500
501  reserved 1;
502}
503
504message FileCount {
505  // The file extension
506  optional string extension = 1;
507
508  // Number of added files with this extension.
509  optional uint32 additions = 2;
510
511  // Number of modified files with this extension.
512  optional uint32 modifications = 3;
513
514  // Number of deleted files with this extension.
515  optional uint32 deletions = 4;
516}
517