Merge "Remove Bazel metrics/finalize-bazel-metrics." into main
This commit is contained in:
@@ -91,14 +91,6 @@ var commands = []command{
|
|||||||
config: buildActionConfig,
|
config: buildActionConfig,
|
||||||
stdio: stdio,
|
stdio: stdio,
|
||||||
run: runMake,
|
run: runMake,
|
||||||
}, {
|
|
||||||
flag: "--finalize-bazel-metrics",
|
|
||||||
description: "finalize b metrics and upload",
|
|
||||||
config: build.UploadOnlyConfig,
|
|
||||||
stdio: stdio,
|
|
||||||
// Finalize-bazel-metrics mode updates metrics files and calls the metrics
|
|
||||||
// uploader. This marks the end of a b invocation.
|
|
||||||
run: finalizeBazelMetrics,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,7 +191,6 @@ func main() {
|
|||||||
soongMetricsFile := filepath.Join(logsDir, c.logsPrefix+"soong_metrics")
|
soongMetricsFile := filepath.Join(logsDir, c.logsPrefix+"soong_metrics")
|
||||||
rbeMetricsFile := filepath.Join(logsDir, c.logsPrefix+"rbe_metrics.pb")
|
rbeMetricsFile := filepath.Join(logsDir, c.logsPrefix+"rbe_metrics.pb")
|
||||||
bp2buildMetricsFile := filepath.Join(logsDir, c.logsPrefix+"bp2build_metrics.pb")
|
bp2buildMetricsFile := filepath.Join(logsDir, c.logsPrefix+"bp2build_metrics.pb")
|
||||||
bazelMetricsFile := filepath.Join(logsDir, c.logsPrefix+"bazel_metrics.pb")
|
|
||||||
soongBuildMetricsFile := filepath.Join(logsDir, c.logsPrefix+"soong_build_metrics.pb")
|
soongBuildMetricsFile := filepath.Join(logsDir, c.logsPrefix+"soong_build_metrics.pb")
|
||||||
|
|
||||||
metricsFiles := []string{
|
metricsFiles := []string{
|
||||||
@@ -207,7 +198,6 @@ func main() {
|
|||||||
rbeMetricsFile, // high level metrics related to remote build execution.
|
rbeMetricsFile, // high level metrics related to remote build execution.
|
||||||
bp2buildMetricsFile, // high level metrics related to bp2build.
|
bp2buildMetricsFile, // high level metrics related to bp2build.
|
||||||
soongMetricsFile, // high level metrics related to this build system.
|
soongMetricsFile, // high level metrics related to this build system.
|
||||||
bazelMetricsFile, // high level metrics related to bazel execution
|
|
||||||
soongBuildMetricsFile, // high level metrics related to soong build(except bp2build)
|
soongBuildMetricsFile, // high level metrics related to soong build(except bp2build)
|
||||||
config.BazelMetricsDir(), // directory that contains a set of bazel metrics.
|
config.BazelMetricsDir(), // directory that contains a set of bazel metrics.
|
||||||
}
|
}
|
||||||
@@ -247,10 +237,9 @@ func logAndSymlinkSetup(buildCtx build.Context, config build.Config) {
|
|||||||
soongMetricsFile := filepath.Join(logsDir, logsPrefix+"soong_metrics")
|
soongMetricsFile := filepath.Join(logsDir, logsPrefix+"soong_metrics")
|
||||||
bp2buildMetricsFile := filepath.Join(logsDir, logsPrefix+"bp2build_metrics.pb")
|
bp2buildMetricsFile := filepath.Join(logsDir, logsPrefix+"bp2build_metrics.pb")
|
||||||
soongBuildMetricsFile := filepath.Join(logsDir, logsPrefix+"soong_build_metrics.pb")
|
soongBuildMetricsFile := filepath.Join(logsDir, logsPrefix+"soong_build_metrics.pb")
|
||||||
bazelMetricsFile := filepath.Join(logsDir, logsPrefix+"bazel_metrics.pb")
|
|
||||||
|
|
||||||
//Delete the stale metrics files
|
//Delete the stale metrics files
|
||||||
staleFileSlice := []string{buildErrorFile, rbeMetricsFile, soongMetricsFile, bp2buildMetricsFile, soongBuildMetricsFile, bazelMetricsFile}
|
staleFileSlice := []string{buildErrorFile, rbeMetricsFile, soongMetricsFile, bp2buildMetricsFile, soongBuildMetricsFile}
|
||||||
if err := deleteStaleMetrics(staleFileSlice); err != nil {
|
if err := deleteStaleMetrics(staleFileSlice); err != nil {
|
||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
@@ -701,28 +690,3 @@ func setMaxFiles(ctx build.Context) {
|
|||||||
ctx.Println("Failed to increase file limit:", err)
|
ctx.Println("Failed to increase file limit:", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func finalizeBazelMetrics(ctx build.Context, config build.Config, args []string) {
|
|
||||||
updateTotalRealTime(ctx, config, args)
|
|
||||||
|
|
||||||
logsDir := config.LogsDir()
|
|
||||||
logsPrefix := config.GetLogsPrefix()
|
|
||||||
bazelMetricsFile := filepath.Join(logsDir, logsPrefix+"bazel_metrics.pb")
|
|
||||||
bazelProfileFile := filepath.Join(logsDir, logsPrefix+"analyzed_bazel_profile.txt")
|
|
||||||
build.ProcessBazelMetrics(bazelProfileFile, bazelMetricsFile, ctx, config)
|
|
||||||
}
|
|
||||||
func updateTotalRealTime(ctx build.Context, config build.Config, args []string) {
|
|
||||||
soongMetricsFile := filepath.Join(config.LogsDir(), "soong_metrics")
|
|
||||||
|
|
||||||
//read file into proto
|
|
||||||
data, err := os.ReadFile(soongMetricsFile)
|
|
||||||
if err != nil {
|
|
||||||
ctx.Fatal(err)
|
|
||||||
}
|
|
||||||
met := ctx.ContextImpl.Metrics
|
|
||||||
|
|
||||||
err = met.UpdateTotalRealTimeAndNonZeroExit(data, config.BazelExitCode())
|
|
||||||
if err != nil {
|
|
||||||
ctx.Fatal(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@@ -205,21 +205,6 @@ func loadEnvConfig(ctx Context, config *configImpl, bc string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func UploadOnlyConfig(ctx Context, args ...string) Config {
|
|
||||||
ret := &configImpl{
|
|
||||||
environ: OsEnvironment(),
|
|
||||||
sandboxConfig: &SandboxConfig{},
|
|
||||||
}
|
|
||||||
ret.parseArgs(ctx, args)
|
|
||||||
srcDir := absPath(ctx, ".")
|
|
||||||
bc := os.Getenv("ANDROID_BUILD_ENVIRONMENT_CONFIG")
|
|
||||||
if err := loadEnvConfig(ctx, ret, bc); err != nil {
|
|
||||||
ctx.Fatalln("Failed to parse env config files: %v", err)
|
|
||||||
}
|
|
||||||
ret.metricsUploader = GetMetricsUploader(srcDir, ret.environ)
|
|
||||||
return Config{ret}
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewConfig(ctx Context, args ...string) Config {
|
func NewConfig(ctx Context, args ...string) Config {
|
||||||
ret := &configImpl{
|
ret := &configImpl{
|
||||||
environ: OsEnvironment(),
|
environ: OsEnvironment(),
|
||||||
@@ -822,16 +807,6 @@ func (c *configImpl) parseArgs(ctx Context, args []string) {
|
|||||||
}
|
}
|
||||||
} else if arg == "--ensure-allowlist-integrity" {
|
} else if arg == "--ensure-allowlist-integrity" {
|
||||||
c.ensureAllowlistIntegrity = true
|
c.ensureAllowlistIntegrity = true
|
||||||
} else if strings.HasPrefix(arg, "--bazel-exit-code=") {
|
|
||||||
bazelExitCodeStr := strings.TrimPrefix(arg, "--bazel-exit-code=")
|
|
||||||
val, err := strconv.Atoi(bazelExitCodeStr)
|
|
||||||
if err == nil {
|
|
||||||
c.bazelExitCode = int32(val)
|
|
||||||
} else {
|
|
||||||
ctx.Fatalf("Error parsing bazel-exit-code", err)
|
|
||||||
}
|
|
||||||
} else if strings.HasPrefix(arg, "--bes-id=") {
|
|
||||||
c.besId = strings.TrimPrefix(arg, "--bes-id=")
|
|
||||||
} else if len(arg) > 0 && arg[0] == '-' {
|
} else if len(arg) > 0 && arg[0] == '-' {
|
||||||
parseArgNum := func(def int) int {
|
parseArgNum := func(def int) int {
|
||||||
if len(arg) > 2 {
|
if len(arg) > 2 {
|
||||||
|
@@ -32,7 +32,6 @@ package metrics
|
|||||||
// of what an event is and how the metrics system is a stack based system.
|
// of what an event is and how the metrics system is a stack based system.
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -228,20 +227,6 @@ func (m *Metrics) SetBuildDateTime(buildTimestamp time.Time) {
|
|||||||
m.metrics.BuildDateTimestamp = proto.Int64(buildTimestamp.UnixNano() / int64(time.Second))
|
m.metrics.BuildDateTimestamp = proto.Int64(buildTimestamp.UnixNano() / int64(time.Second))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Metrics) UpdateTotalRealTimeAndNonZeroExit(data []byte, bazelExitCode int32) error {
|
|
||||||
if err := proto.Unmarshal(data, &m.metrics); err != nil {
|
|
||||||
return fmt.Errorf("Failed to unmarshal proto: %w", err)
|
|
||||||
}
|
|
||||||
startTime := *m.metrics.Total.StartTime
|
|
||||||
endTime := uint64(time.Now().UnixNano())
|
|
||||||
|
|
||||||
*m.metrics.Total.RealTime = *proto.Uint64(endTime - startTime)
|
|
||||||
|
|
||||||
bazelError := bazelExitCode != 0
|
|
||||||
m.metrics.NonZeroExit = proto.Bool(bazelError)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// SetBuildCommand adds the build command specified by the user to the
|
// SetBuildCommand adds the build command specified by the user to the
|
||||||
// list of collected metrics.
|
// list of collected metrics.
|
||||||
func (m *Metrics) SetBuildCommand(cmd []string) {
|
func (m *Metrics) SetBuildCommand(cmd []string) {
|
||||||
|
Reference in New Issue
Block a user