Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cd7db257 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes I7ec5a9f7,I76807f9b

* changes:
  Add docstrings for CriticalPathInfo
  Add long running jobs info
parents 58fa5a3f cf833776
Loading
Loading
Loading
Loading
+32 −15
Original line number Diff line number Diff line
@@ -1437,6 +1437,8 @@ func (x *MixedBuildsInfo) GetMixedBuildDisabledModules() []string {
	return nil
}

// CriticalPathInfo contains critical path nodes's information.
// A critical path is a path determining the minimum time needed for the whole build given perfect parallelism.
type CriticalPathInfo struct {
	state         protoimpl.MessageState
	sizeCache     protoimpl.SizeCache
@@ -1448,6 +1450,8 @@ type CriticalPathInfo struct {
	CriticalPathTime *uint64 `protobuf:"varint,2,opt,name=critical_path_time,json=criticalPathTime" json:"critical_path_time,omitempty"`
	// Detailed job information in a critical path.
	CriticalPath []*JobInfo `protobuf:"bytes,4,rep,name=critical_path,json=criticalPath" json:"critical_path,omitempty"`
	// Detailed job information for long running jobs (>30 seconds). These may or may not also be on a critical path.
	LongRunningJobs []*JobInfo `protobuf:"bytes,5,rep,name=long_running_jobs,json=longRunningJobs" json:"long_running_jobs,omitempty"`
}

func (x *CriticalPathInfo) Reset() {
@@ -1503,6 +1507,13 @@ func (x *CriticalPathInfo) GetCriticalPath() []*JobInfo {
	return nil
}

func (x *CriticalPathInfo) GetLongRunningJobs() []*JobInfo {
	if x != nil {
		return x.LongRunningJobs
	}
	return nil
}

type JobInfo struct {
	state         protoimpl.MessageState
	sizeCache     protoimpl.SizeCache
@@ -1831,7 +1842,7 @@ var file_metrics_proto_rawDesc = []byte{
	0x5f, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x5f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65,
	0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x19, 0x6d, 0x69, 0x78, 0x65, 0x64, 0x42, 0x75,
	0x69, 0x6c, 0x64, 0x44, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x4d, 0x6f, 0x64, 0x75, 0x6c,
	0x65, 0x73, 0x22, 0xa6, 0x01, 0x0a, 0x10, 0x43, 0x72, 0x69, 0x74, 0x69, 0x63, 0x61, 0x6c, 0x50,
	0x65, 0x73, 0x22, 0xf0, 0x01, 0x0a, 0x10, 0x43, 0x72, 0x69, 0x74, 0x69, 0x63, 0x61, 0x6c, 0x50,
	0x61, 0x74, 0x68, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x21, 0x0a, 0x0c, 0x65, 0x6c, 0x61, 0x70, 0x73,
	0x65, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x65,
	0x6c, 0x61, 0x70, 0x73, 0x65, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x2c, 0x0a, 0x12, 0x63, 0x72,
@@ -1841,15 +1852,20 @@ var file_metrics_proto_rawDesc = []byte{
	0x69, 0x63, 0x61, 0x6c, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32,
	0x1c, 0x2e, 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x5f, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x5f, 0x6d, 0x65,
	0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x4a, 0x6f, 0x62, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0c, 0x63,
	0x72, 0x69, 0x74, 0x69, 0x63, 0x61, 0x6c, 0x50, 0x61, 0x74, 0x68, 0x22, 0x55, 0x0a, 0x07, 0x4a,
	0x6f, 0x62, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x21, 0x0a, 0x0c, 0x65, 0x6c, 0x61, 0x70, 0x73, 0x65,
	0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x65, 0x6c,
	0x61, 0x70, 0x73, 0x65, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x6a, 0x6f, 0x62,
	0x5f, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01,
	0x28, 0x09, 0x52, 0x0e, 0x6a, 0x6f, 0x62, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69,
	0x6f, 0x6e, 0x42, 0x28, 0x5a, 0x26, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2f, 0x73, 0x6f,
	0x6f, 0x6e, 0x67, 0x2f, 0x75, 0x69, 0x2f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2f, 0x6d,
	0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
	0x72, 0x69, 0x74, 0x69, 0x63, 0x61, 0x6c, 0x50, 0x61, 0x74, 0x68, 0x12, 0x48, 0x0a, 0x11, 0x6c,
	0x6f, 0x6e, 0x67, 0x5f, 0x72, 0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67, 0x5f, 0x6a, 0x6f, 0x62, 0x73,
	0x18, 0x05, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1c, 0x2e, 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x5f, 0x62,
	0x75, 0x69, 0x6c, 0x64, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2e, 0x4a, 0x6f, 0x62,
	0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0f, 0x6c, 0x6f, 0x6e, 0x67, 0x52, 0x75, 0x6e, 0x6e, 0x69, 0x6e,
	0x67, 0x4a, 0x6f, 0x62, 0x73, 0x22, 0x55, 0x0a, 0x07, 0x4a, 0x6f, 0x62, 0x49, 0x6e, 0x66, 0x6f,
	0x12, 0x21, 0x0a, 0x0c, 0x65, 0x6c, 0x61, 0x70, 0x73, 0x65, 0x64, 0x5f, 0x74, 0x69, 0x6d, 0x65,
	0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0b, 0x65, 0x6c, 0x61, 0x70, 0x73, 0x65, 0x64, 0x54,
	0x69, 0x6d, 0x65, 0x12, 0x27, 0x0a, 0x0f, 0x6a, 0x6f, 0x62, 0x5f, 0x64, 0x65, 0x73, 0x63, 0x72,
	0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x6a, 0x6f,
	0x62, 0x44, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x28, 0x5a, 0x26,
	0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2f, 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x2f, 0x75, 0x69,
	0x2f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73, 0x2f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x73,
	0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
}

var (
@@ -1909,11 +1925,12 @@ var file_metrics_proto_depIdxs = []int32{
	14, // 20: soong_build_metrics.SoongBuildMetrics.mixed_builds_info:type_name -> soong_build_metrics.MixedBuildsInfo
	3,  // 21: soong_build_metrics.ExpConfigFetcher.status:type_name -> soong_build_metrics.ExpConfigFetcher.ConfigStatus
	16, // 22: soong_build_metrics.CriticalPathInfo.critical_path:type_name -> soong_build_metrics.JobInfo
	23, // [23:23] is the sub-list for method output_type
	23, // [23:23] is the sub-list for method input_type
	23, // [23:23] is the sub-list for extension type_name
	23, // [23:23] is the sub-list for extension extendee
	0,  // [0:23] is the sub-list for field type_name
	16, // 23: soong_build_metrics.CriticalPathInfo.long_running_jobs:type_name -> soong_build_metrics.JobInfo
	24, // [24:24] is the sub-list for method output_type
	24, // [24:24] is the sub-list for method input_type
	24, // [24:24] is the sub-list for extension type_name
	24, // [24:24] is the sub-list for extension extendee
	0,  // [0:24] is the sub-list for field type_name
}

func init() { file_metrics_proto_init() }
+6 −2
Original line number Diff line number Diff line
@@ -318,6 +318,8 @@ message MixedBuildsInfo{
  repeated string mixed_build_disabled_modules = 2;
}

// CriticalPathInfo contains critical path nodes's information.
// A critical path is a path determining the minimum time needed for the whole build given perfect parallelism.
message CriticalPathInfo {
  // Real time which the build system spent
  optional uint64 elapsed_time = 1;
@@ -325,6 +327,8 @@ message CriticalPathInfo{
  optional uint64 critical_path_time = 2;
  // Detailed job information in a critical path.
  repeated JobInfo critical_path = 4;
  // Detailed job information for long running jobs (>30 seconds). These may or may not also be on a critical path.
  repeated JobInfo long_running_jobs = 5;
}

message JobInfo {
+21 −6
Original line number Diff line number Diff line
@@ -127,16 +127,31 @@ func (cp *CriticalPath) criticalPath() (path []*node, elapsedTime time.Duration,
	return
}

func (cp *CriticalPath) longRunningJobs() (nodes []*node) {
	threshold := time.Second * 30
	for _, node := range cp.nodes {
		if node != nil && node.duration > threshold {
			nodes = append(nodes, node)
		}
	}
	return
}

func addJobInfos(jobInfos *[]*soong_metrics_proto.JobInfo, sources []*node) {
	for _, job := range sources {
		jobInfo := soong_metrics_proto.JobInfo{}
		jobInfo.ElapsedTime = proto.Uint64(uint64(job.duration.Microseconds()))
		jobInfo.JobDescription = &job.action.Description
		*jobInfos = append(*jobInfos, &jobInfo)
	}
}

func (cp *CriticalPath) WriteToMetrics(met *metrics.Metrics) {
	criticalPathInfo := soong_metrics_proto.CriticalPathInfo{}
	path, elapsedTime, criticalTime := cp.criticalPath()
	criticalPathInfo.ElapsedTime = proto.Uint64(uint64(elapsedTime.Microseconds()))
	criticalPathInfo.CriticalPathTime = proto.Uint64(uint64(criticalTime.Microseconds()))
	for _, job := range path {
		jobInfo := soong_metrics_proto.JobInfo{}
		jobInfo.ElapsedTime = proto.Uint64(uint64(job.duration.Microseconds()))
		jobInfo.JobDescription = &job.action.Description
		criticalPathInfo.CriticalPath = append(criticalPathInfo.CriticalPath, &jobInfo)
	}
	addJobInfos(&criticalPathInfo.LongRunningJobs, cp.longRunningJobs())
	addJobInfos(&criticalPathInfo.CriticalPath, path)
	met.SetCriticalPathInfo(criticalPathInfo)
}