-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Potential OOM error #338
Comments
It seems like C8 is suffering from the same memory issue NYC used to suffer from Related tickets: bcoe/c8#338 istanbuljs/nyc#1263
I can reproduce this OOM error in an open-source project. It seems like the issue is caused by the number (464) and size (0.5MB-8MB each) of tmp files required to generate the coverage report and the fact that C8 tries to load them all into memory before processing (as per @canonic-epicure's point above). I'm happy to share the output needed to reproduce the problem; it's ~300 MB, so I can't attach it to the ticket.
I believe that the large number of tmp files produced by C8 is caused by C8 producing a tmp file per process. I have over a dozen components (Node modules) in my project, many of which run integration tests using Mocha with The report aggregation command (
Proposed solution@bcoe - would it make sense to make the Lines 246 to 259 in 2f36fe9
cache each entry using the same strategy Lines 177 to 188 in 2f36fe9
So something like this, perhaps: _loadReports () {
const { mergeProcessCovs } = require('@bcoe/v8-coverage')
try {
const v8ProcessCovs = []
for (const file of readdirSync(this.tempDirectory)) {
const v8ProcessCov = JSON.parse(readFileSync(
resolve(this.tempDirectory, file),
'utf8'
))
if (this._isCoverageObject(v8ProcessCov)) {
if (v8ProcessCov['source-map-cache']) {
Object.assign(this.sourceMapCache, this._normalizeSourceMapCache(v8ProcessCov['source-map-cache']))
}
v8ProcessCovs.push(this._normalizeProcessCov(v8ProcessCov, fileIndex))
}
return v8ProcessCovs;
}
} catch (error) {
debuglog(`${err.stack}`)
throw error;
}
} I'm happy to propose a PR if you agree with the approach, @bcoe? |
@jan-molak do you think you can test my PR #469? We were having the same issues and after applying my fix we are not. |
It seems like C8 is suffering from the same memory issue NYC used to suffer from Related tickets: bcoe/c8#338 istanbuljs/nyc#1263
…by c8 enabling the --merge-async flag helps to avoid c8 running out of memory, see bcoe/c8#338
@bizob2828 - apologies for not getting back to you sooner, and thanks for your work on #469. |
…18910) ## Description This should resolve the intermittent OOM issues we've been seeing on CI. The cause of them appears was [this issue](bcoe/c8#338), as by default c8 attempts to merge coverage reports by loading them all into memory at the same time. Our root c8 config includes many files, so this can trigger OOM issues. I've updated the repo to [email protected], since we needed to bump the c8 dependency anyway to use the merge-async option and the only breaking change between 7 and 8 was dropping node 10 support. --------- Co-authored-by: Abram Sanderson <[email protected]>
I just noticed that
c8
will probably suffer from the same OOM issue as nyc: istanbuljs/nyc#1263It is caused by the fact, that it tries to load all reports in memory first and then merge them. Instead, should load and merge one-by-one (or by certain limit).
The text was updated successfully, but these errors were encountered: