Skip to content

Commit

Permalink
fix: fsync: false when writing cache files
Browse files Browse the repository at this point in the history
We're using writeFileAtomic here in order to get atomic rename, not
to get full system power failure resilience. Most(tm) filesystems
will guarantee either/or during a crash here, which is plenty
enough for us.

fsync is a nearly 3x slowdown for me, ts-jest'ing my whole codebase
(~900 files in testcase).
  • Loading branch information
FauxFaux committed Mar 23, 2020
1 parent 4a59daa commit 5146ec0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -7,6 +7,7 @@
- `[jest-haste-map]` [**BREAKING**] Remove `mapper` option ([#9581](https://github.com/facebook/jest/pull/9581))
- `[*]` Support array of paths for `moduleNameMapper` aliases ([#9465](https://github.com/facebook/jest/pull/9465))
- `[jest-reporters]` Adds ability to pass options to the istanbul-reporter through `coverageReporters` ([#9572](https://github.com/facebook/jest/pull/9572))
- `[jest-transform]` `writeCacheFile` no longer calls `fsync` ([#9605](https://github.com/facebook/jest/pull/9572))

### Fixes

Expand Down
2 changes: 1 addition & 1 deletion packages/jest-transform/src/ScriptTransformer.ts
Expand Up @@ -630,7 +630,7 @@ function readCodeCacheFile(cachePath: Config.Path): string | null {
*/
const writeCacheFile = (cachePath: Config.Path, fileData: string) => {
try {
writeFileAtomic(cachePath, fileData, {encoding: 'utf8'});
writeFileAtomic(cachePath, fileData, {encoding: 'utf8', fsync: false});
} catch (e) {
if (cacheWriteErrorSafeToIgnore(e, cachePath)) {
return;
Expand Down

0 comments on commit 5146ec0

Please sign in to comment.