Skip to content

Commit a96ff53

Browse files
thomasbrelanderegon
authored andcommitted
Scale bundler install jobs with CPU count up to 8
The number of jobs should scale with the runner CPU count, up to a point. The bottleneck becomes network / disk I/O at very large numbers, and 8 seems like a reasonable maximum based on my experience at this time.
1 parent 4ff6f36 commit a96ff53

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

bundler.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const fs = require('fs')
2+
const os = require('os')
23
const path = require('path')
34
const core = require('@actions/core')
45
const exec = require('@actions/exec')
@@ -193,8 +194,10 @@ export async function bundleInstall(gemfile, lockFile, platform, engine, rubyVer
193194
console.log(`Found cache for key: ${cachedKey}`)
194195
}
195196

197+
// Number of jobs should scale with runner, up to a point
198+
const jobs = Math.min(os.cpus().length, 8)
196199
// Always run 'bundle install' to list the gems
197-
await exec.exec('bundle', ['install', '--jobs', '4'])
200+
await exec.exec('bundle', ['install', '--jobs', jobs])
198201

199202
// @actions/cache only allows to save for non-existing keys
200203
if (!common.isExactCacheKeyMatch(key, cachedKey)) {

dist/index.js

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)