Skip to content

Commit

Permalink
feat: add env var for setting max task concurrency
Browse files Browse the repository at this point in the history
The GARDEN_TASK_CONCURRENCY_LIMIT env variable can now be used to
override the task graph's default concurrency limit. Values should be
integers.

Also set this env variable to 10 in our CircleCI config.
  • Loading branch information
thsig committed Jul 9, 2019
1 parent 9c42309 commit c3383d2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ version: 2.1
- image: circleci/node:10
environment:
GARDEN_DISABLE_VERSION_CHECK: "true"
GARDEN_TASK_CONCURRENCY_LIMIT: "10"

# Attach's the current saved workspace
attach-workspace: &attach-workspace
Expand Down
6 changes: 5 additions & 1 deletion garden-service/src/task-graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export interface TaskResults {

export const DEFAULT_CONCURRENCY = 6

const concurrencyFromEnv = process.env.GARDEN_TASK_CONCURRENCY_LIMIT

export const TASK_CONCURRENCY = (concurrencyFromEnv && parseInt(concurrencyFromEnv, 10)) || DEFAULT_CONCURRENCY

export class TaskGraph {
private roots: TaskNodeMap
private index: TaskNodeMap
Expand All @@ -57,7 +61,7 @@ export class TaskGraph {
private resultCache: ResultCache
private opQueue: PQueue

constructor(private garden: Garden, private log: LogEntry, private concurrency: number = DEFAULT_CONCURRENCY) {
constructor(private garden: Garden, private log: LogEntry, private concurrency: number = TASK_CONCURRENCY) {
this.roots = new TaskNodeMap()
this.index = new TaskNodeMap()
this.inProgress = new TaskNodeMap()
Expand Down

0 comments on commit c3383d2

Please sign in to comment.