Share a lazy source index across cache hits
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/core/source"
|
||||
@@ -70,6 +71,8 @@ type RunInput struct {
|
||||
stepID string
|
||||
references map[referenceTargetKey]contracts.ReferenceSet
|
||||
referenceReuseEligibility map[referenceTargetKey]bool
|
||||
// Shared by operation decoders, but built only when a cache hit needs it.
|
||||
cacheSourceIndex func() source.DocumentIndex
|
||||
}
|
||||
|
||||
type RunOutput struct {
|
||||
@@ -182,6 +185,9 @@ func (r *Runner) Run(ctx context.Context, input RunInput) (output RunOutput, err
|
||||
if err := source.ValidateDocument(doc); err != nil {
|
||||
return failOutput(output), fmt.Errorf("validate source document: %w", err)
|
||||
}
|
||||
input.cacheSourceIndex = sync.OnceValue(func() source.DocumentIndex {
|
||||
return source.NewDocumentIndex(doc)
|
||||
})
|
||||
|
||||
if err := writeDebugTimed(debugRecorder, "source/output.json", debugTimedEnvelope{
|
||||
Stage: "source",
|
||||
|
||||
Reference in New Issue
Block a user