Skip to content

Commit

Permalink
Revert "Add cache state to task summaries on real runs"
Browse files Browse the repository at this point in the history
This reverts commit 142165a.
  • Loading branch information
mehulkar committed Mar 16, 2023
1 parent 142165a commit 4e8f85e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 44 deletions.
8 changes: 4 additions & 4 deletions cli/internal/run/dry_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ func DryRun(
return err
}

// Assign the Task Summaries to the main summary
summary.Tasks = taskSummaries

// We walk the graph with no concurrency.
// Populating the cache state is parallelizable.
// Do this _after_ walking the graph.
summary.PopulateCacheState(turboCache)
populateCacheState(turboCache, taskSummaries)

// Assign the Task Summaries to the main summary
summary.Tasks = taskSummaries

// Render the dry run as json
if dryRunJSON {
Expand Down
5 changes: 0 additions & 5 deletions cli/internal/run/real_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,6 @@ func RealRun(
// Assign tasks after execution
runSummary.Tasks = taskSummaries

// We walk the graph with no concurrency.
// Populating the cache state is parallelizable.
// Do this _after_ walking the graph.
runSummary.PopulateCacheState(turboCache)

for _, err := range errs {
if errors.As(err, &exitCodeErr) {
if exitCodeErr.ExitCode > exitCode {
Expand Down
35 changes: 0 additions & 35 deletions cli/internal/runsummary/run_summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package runsummary
import (
"fmt"
"path/filepath"
"sync"
"time"

"github.com/mitchellh/cli"
Expand Down Expand Up @@ -47,40 +46,6 @@ func NewRunSummary(startAt time.Time, profile string, turboVersion string, packa
}
}

// PopulateCacheState sets the CacheState field on each of the TaskSummaries
func (summary *RunSummary) PopulateCacheState(turboCache cache.Cache) {
taskSummaries := summary.Tasks
// We make at most 8 requests at a time for cache state.
maxParallelRequests := 8
taskCount := len(taskSummaries)

parallelRequestCount := maxParallelRequests
if taskCount < maxParallelRequests {
parallelRequestCount = taskCount
}

queue := make(chan int, taskCount)

wg := &sync.WaitGroup{}
for i := 0; i < parallelRequestCount; i++ {
wg.Add(1)
go func() {
defer wg.Done()
for index := range queue {
task := taskSummaries[index]
itemStatus := turboCache.Exists(task.Hash)
task.CacheState = itemStatus
}
}()
}

for index := range taskSummaries {
queue <- index
}
close(queue)
wg.Wait()
}

// Close wraps up the RunSummary at the end of a `turbo run`.
func (summary *RunSummary) Close(terminal cli.Ui) {
if err := writeChrometracing(summary.ExecutionSummary.profileFilename, terminal); err != nil {
Expand Down

0 comments on commit 4e8f85e

Please sign in to comment.