Loading ui/build/soong.go +0 −54 Original line number Diff line number Diff line Loading @@ -15,16 +15,13 @@ package build import ( "errors" "fmt" "io/fs" "os" "path/filepath" "strconv" "strings" "android/soong/ui/metrics" soong_metrics_proto "android/soong/ui/metrics/metrics_proto" "android/soong/ui/status" "android/soong/shared" Loading @@ -32,8 +29,6 @@ import ( "github.com/google/blueprint" "github.com/google/blueprint/bootstrap" "github.com/google/blueprint/microfactory" "google.golang.org/protobuf/proto" ) const ( Loading Loading @@ -566,22 +561,6 @@ func runSoong(ctx Context, config Config) { targets = append(targets, config.SoongNinjaFile()) } // TODO(juu): Stop embedding soong_build_metrics in soong_metrics. soongBuildMetricsFile := filepath.Join(config.LogsDir(), "soong_build_metrics.pb") if err := os.Remove(soongBuildMetricsFile); err != nil && !os.IsNotExist(err) { ctx.Verbosef("Failed to remove %s", soongBuildMetricsFile) } if shouldCollectBuildSoongMetrics(config) { defer func() { soongBuildMetrics := loadSoongBuildMetrics(ctx, soongBuildMetricsFile) if soongBuildMetrics != nil { logSoongBuildMetrics(ctx, soongBuildMetrics) if ctx.Metrics != nil { ctx.Metrics.SetSoongBuildMetrics(soongBuildMetrics) } } }() } ninja("bootstrap", "bootstrap.ninja", targets...) distGzipFile(ctx, config, config.SoongNinjaFile(), "soong") Loading Loading @@ -614,36 +593,3 @@ func runMicrofactory(ctx Context, config Config, name string, pkg string, mappin ctx.Fatalf("failed to build %s: %s", name, err) } } func shouldCollectBuildSoongMetrics(config Config) bool { // Do not collect metrics protobuf if the soong_build binary ran as the // bp2build converter or the JSON graph dump. return config.SoongBuildInvocationNeeded() } func loadSoongBuildMetrics(ctx Context, soongBuildMetricsFile string) *soong_metrics_proto.SoongBuildMetrics { buf, err := os.ReadFile(soongBuildMetricsFile) if errors.Is(err, fs.ErrNotExist) { // Soong may not have run during this invocation ctx.Verbosef("Failed to read metrics file, %s: %s", soongBuildMetricsFile, err) return nil } else if err != nil { ctx.Fatalf("Failed to load %s: %s", soongBuildMetricsFile, err) } soongBuildMetrics := &soong_metrics_proto.SoongBuildMetrics{} err = proto.Unmarshal(buf, soongBuildMetrics) if err != nil { ctx.Fatalf("Failed to unmarshal %s: %s", soongBuildMetricsFile, err) } return soongBuildMetrics } func logSoongBuildMetrics(ctx Context, metrics *soong_metrics_proto.SoongBuildMetrics) { ctx.Verbosef("soong_build metrics:") ctx.Verbosef(" modules: %v", metrics.GetModules()) ctx.Verbosef(" variants: %v", metrics.GetVariants()) ctx.Verbosef(" max heap size: %v MB", metrics.GetMaxHeapSize()/1e6) ctx.Verbosef(" total allocation count: %v", metrics.GetTotalAllocCount()) ctx.Verbosef(" total allocation size: %v MB", metrics.GetTotalAllocSize()/1e6) } ui/metrics/metrics_proto/metrics.pb.go +194 −189 File changed.Preview size limit exceeded, changes collapsed. Show changes ui/metrics/metrics_proto/metrics.proto +3 −1 Original line number Diff line number Diff line Loading @@ -93,7 +93,9 @@ message MetricsBase { // The metrics for the whole build optional PerfInfo total = 21; optional SoongBuildMetrics soong_build_metrics = 22; // Deprecated because instead of embedding in a MetricsBase, we keep // SoongBuildMetrics in its own file optional SoongBuildMetrics soong_build_metrics = 22 [deprecated=true]; optional BuildConfig build_config = 23; Loading Loading
ui/build/soong.go +0 −54 Original line number Diff line number Diff line Loading @@ -15,16 +15,13 @@ package build import ( "errors" "fmt" "io/fs" "os" "path/filepath" "strconv" "strings" "android/soong/ui/metrics" soong_metrics_proto "android/soong/ui/metrics/metrics_proto" "android/soong/ui/status" "android/soong/shared" Loading @@ -32,8 +29,6 @@ import ( "github.com/google/blueprint" "github.com/google/blueprint/bootstrap" "github.com/google/blueprint/microfactory" "google.golang.org/protobuf/proto" ) const ( Loading Loading @@ -566,22 +561,6 @@ func runSoong(ctx Context, config Config) { targets = append(targets, config.SoongNinjaFile()) } // TODO(juu): Stop embedding soong_build_metrics in soong_metrics. soongBuildMetricsFile := filepath.Join(config.LogsDir(), "soong_build_metrics.pb") if err := os.Remove(soongBuildMetricsFile); err != nil && !os.IsNotExist(err) { ctx.Verbosef("Failed to remove %s", soongBuildMetricsFile) } if shouldCollectBuildSoongMetrics(config) { defer func() { soongBuildMetrics := loadSoongBuildMetrics(ctx, soongBuildMetricsFile) if soongBuildMetrics != nil { logSoongBuildMetrics(ctx, soongBuildMetrics) if ctx.Metrics != nil { ctx.Metrics.SetSoongBuildMetrics(soongBuildMetrics) } } }() } ninja("bootstrap", "bootstrap.ninja", targets...) distGzipFile(ctx, config, config.SoongNinjaFile(), "soong") Loading Loading @@ -614,36 +593,3 @@ func runMicrofactory(ctx Context, config Config, name string, pkg string, mappin ctx.Fatalf("failed to build %s: %s", name, err) } } func shouldCollectBuildSoongMetrics(config Config) bool { // Do not collect metrics protobuf if the soong_build binary ran as the // bp2build converter or the JSON graph dump. return config.SoongBuildInvocationNeeded() } func loadSoongBuildMetrics(ctx Context, soongBuildMetricsFile string) *soong_metrics_proto.SoongBuildMetrics { buf, err := os.ReadFile(soongBuildMetricsFile) if errors.Is(err, fs.ErrNotExist) { // Soong may not have run during this invocation ctx.Verbosef("Failed to read metrics file, %s: %s", soongBuildMetricsFile, err) return nil } else if err != nil { ctx.Fatalf("Failed to load %s: %s", soongBuildMetricsFile, err) } soongBuildMetrics := &soong_metrics_proto.SoongBuildMetrics{} err = proto.Unmarshal(buf, soongBuildMetrics) if err != nil { ctx.Fatalf("Failed to unmarshal %s: %s", soongBuildMetricsFile, err) } return soongBuildMetrics } func logSoongBuildMetrics(ctx Context, metrics *soong_metrics_proto.SoongBuildMetrics) { ctx.Verbosef("soong_build metrics:") ctx.Verbosef(" modules: %v", metrics.GetModules()) ctx.Verbosef(" variants: %v", metrics.GetVariants()) ctx.Verbosef(" max heap size: %v MB", metrics.GetMaxHeapSize()/1e6) ctx.Verbosef(" total allocation count: %v", metrics.GetTotalAllocCount()) ctx.Verbosef(" total allocation size: %v MB", metrics.GetTotalAllocSize()/1e6) }
ui/metrics/metrics_proto/metrics.pb.go +194 −189 File changed.Preview size limit exceeded, changes collapsed. Show changes
ui/metrics/metrics_proto/metrics.proto +3 −1 Original line number Diff line number Diff line Loading @@ -93,7 +93,9 @@ message MetricsBase { // The metrics for the whole build optional PerfInfo total = 21; optional SoongBuildMetrics soong_build_metrics = 22; // Deprecated because instead of embedding in a MetricsBase, we keep // SoongBuildMetrics in its own file optional SoongBuildMetrics soong_build_metrics = 22 [deprecated=true]; optional BuildConfig build_config = 23; Loading