Reuse artifact dependents during analysis

This commit is contained in:
2026-12-02 21:20:37 +00:00
parent 19b720742e
commit 9ae5443073
4 changed files with 15 additions and 33 deletions

View File

@@ -200,11 +200,11 @@ func artifactCfgMap(execution analyzeExecutionContext) map[string]config.Scripto
}
func staleAnalyzeDependents(
configured map[string]config.ScriptoriumArtifactConfig,
graph *artifactdeps.Graph,
changed string,
records map[string]manifest.AnalyzeArtifactRecord,
) {
staleAnalyzeDependentClosure(configured, changed, records, nil)
staleAnalyzeDependentClosure(graph, changed, records, nil)
}
func currentAnalyzeArtifactRecord(
@@ -284,46 +284,25 @@ func sameAnalyzeOutputIdentity(left, right manifest.AnalyzeArtifactRecord) bool
}
func staleUnscheduledAnalyzeDependents(
configured map[string]config.ScriptoriumArtifactConfig,
graph *artifactdeps.Graph,
changed string,
currentKeys map[string]struct{},
records map[string]manifest.AnalyzeArtifactRecord,
) {
staleAnalyzeDependentClosure(configured, changed, records, func(key string) bool {
staleAnalyzeDependentClosure(graph, changed, records, func(key string) bool {
_, evaluated := currentKeys[key]
return !evaluated
})
}
func staleAnalyzeDependentClosure(
configured map[string]config.ScriptoriumArtifactConfig,
graph *artifactdeps.Graph,
changed string,
records map[string]manifest.AnalyzeArtifactRecord,
eligible func(string) bool,
) {
reverse := make(map[string][]string, len(configured))
for key, artifactCfg := range configured {
for _, dependency := range artifacts.NormalizedDependencyKeys(artifactCfg.DependsOn) {
reverse[dependency] = append(reverse[dependency], key)
}
}
for key := range reverse {
sort.Strings(reverse[key])
}
queue := append([]string(nil), reverse[changed]...)
seen := make(map[string]struct{}, len(queue))
for len(queue) > 0 {
key := queue[0]
queue = queue[1:]
if _, visited := seen[key]; visited {
continue
}
seen[key] = struct{}{}
if eligible != nil && !eligible(key) {
continue
}
for _, key := range graph.Dependents(changed, eligible) {
staleAnalyzeRecord(records, key)
queue = append(queue, reverse[key]...)
}
}

View File

@@ -93,7 +93,7 @@ func (state *analyzeExecutionState) acceptArtifact(
prior, hadPrior := state.priorCurrentRecords[plan.Name]
if !hadPrior || !sameAnalyzeOutputIdentity(prior, record) {
staleUnscheduledAnalyzeDependents(
artifactCfgMap(state.execution),
state.execution.Graph,
plan.Name,
state.evaluatedKeys,
state.records,
@@ -229,7 +229,7 @@ func (state *analyzeExecutionState) failedResult(
}
}
state.records[item.Key] = record
staleAnalyzeDependents(artifactCfgMap(state.execution), item.Key, state.records)
staleAnalyzeDependents(state.execution.Graph, item.Key, state.records)
state.installManifestCollection()
return &StageResult{}
}