mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-04 20:17:09 +00:00
fix(analyze): read how much of a record's action count names no producer
A runs.jsonl written before actions named one has no field, and its whole count is of unknown provenance rather than none of it.
This commit is contained in:
1 parent
e0180f891a
commit
67c9de6365
1 file changed
+39
-5
@@ -59,6 +59,12 @@ type runRecord struct {
|
|||||||
// rather than read as an arm that acted zero times. The campaign tool always
|
// rather than read as an arm that acted zero times. The campaign tool always
|
||||||
// emits the field, so its absence dates the file.
|
// emits the field, so its absence dates the file.
|
||||||
Actions *int `json:"actions"`
|
Actions *int `json:"actions"`
|
||||||
|
// UnattributedActions is how many of the run's actions name no producer, so
|
||||||
|
// nothing can say whether the spec's setup drove them. It is a pointer
|
||||||
|
// because a runs.jsonl written before actions named a producer at all has no
|
||||||
|
// field, and reading that silence as none would let a denominator of unknown
|
||||||
|
// provenance pass for one that excludes the setup's login.
|
||||||
|
UnattributedActions *int `json:"unattributed_actions"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exclusion reasons. A run that failed or timed out is missing data, not a
|
// Exclusion reasons. A run that failed or timed out is missing data, not a
|
||||||
@@ -73,11 +79,12 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type classifiedRun struct {
|
type classifiedRun struct {
|
||||||
Seed int64
|
Seed int64
|
||||||
Steps int
|
Steps int
|
||||||
Actions int
|
Actions int
|
||||||
MonotonicMillis int64
|
UnattributedActions int
|
||||||
OriginStep int
|
MonotonicMillis int64
|
||||||
|
OriginStep int
|
||||||
// EventStep is when the run could know, and it is what the survival
|
// EventStep is when the run could know, and it is what the survival
|
||||||
// analysis measures. It is the origin step whenever the two agree.
|
// analysis measures. It is the origin step whenever the two agree.
|
||||||
EventStep int
|
EventStep int
|
||||||
@@ -148,6 +155,19 @@ func loadCampaign(directory string) (manifest, []runRecord, error) {
|
|||||||
return declared, records, nil
|
return declared, records, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// unattributedActions is how many of the record's actions carry no producer. A
|
||||||
|
// campaign written before the field existed carries none at all, so its whole
|
||||||
|
// action count is of unknown provenance rather than none of it.
|
||||||
|
func unattributedActions(record runRecord) int {
|
||||||
|
if record.UnattributedActions != nil {
|
||||||
|
return *record.UnattributedActions
|
||||||
|
}
|
||||||
|
if record.Actions == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
return *record.Actions
|
||||||
|
}
|
||||||
|
|
||||||
func (r runRecord) workingMillis() int64 {
|
func (r runRecord) workingMillis() int64 {
|
||||||
if r.MonotonicMillis != 0 {
|
if r.MonotonicMillis != 0 {
|
||||||
return r.MonotonicMillis
|
return r.MonotonicMillis
|
||||||
@@ -167,6 +187,7 @@ func classify(record runRecord, budget int) classifiedRun {
|
|||||||
if record.Actions != nil {
|
if record.Actions != nil {
|
||||||
item.Actions = *record.Actions
|
item.Actions = *record.Actions
|
||||||
}
|
}
|
||||||
|
item.UnattributedActions = unattributedActions(record)
|
||||||
switch {
|
switch {
|
||||||
case record.LaunchError != "":
|
case record.LaunchError != "":
|
||||||
item.ExcludedBecause = reasonLaunchError
|
item.ExcludedBecause = reasonLaunchError
|
||||||
@@ -272,6 +293,19 @@ func groupArms(directories []string) ([]arm, error) {
|
|||||||
return arms, nil
|
return arms, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// unattributedActions is how much of the arm's per-action denominator has no
|
||||||
|
// producer behind it, counted over the runs the denominator is built from.
|
||||||
|
func (a arm) unattributedActions() int {
|
||||||
|
total := 0
|
||||||
|
for _, item := range a.Runs {
|
||||||
|
if item.ExcludedBecause != "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
total += item.UnattributedActions
|
||||||
|
}
|
||||||
|
return total
|
||||||
|
}
|
||||||
|
|
||||||
// observations returns the usable runs as survival data: an event at the step
|
// observations returns the usable runs as survival data: an event at the step
|
||||||
// that armed the first violation, or a censored observation at the last step
|
// that armed the first violation, or a censored observation at the last step
|
||||||
// the run reached.
|
// the run reached.
|
||||||
|
|||||||
Reference in new issue
Block a user