From edccbd6dddce65d70b535d8da6ebb687d1d02d8e Mon Sep 17 00:00:00 2001 From: "Chris West (Faux)" Date: Mon, 23 Mar 2020 21:52:14 +0000 Subject: [PATCH] fix: fsync: false when writing cache files 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). --- CHANGELOG.md | 1 + packages/jest-transform/src/ScriptTransformer.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 169c2270b0f7..56f61ede0f5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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` ([#9695](https://github.com/facebook/jest/pull/9695)) ### Fixes diff --git a/packages/jest-transform/src/ScriptTransformer.ts b/packages/jest-transform/src/ScriptTransformer.ts index ccd18834aa42..a3658842f164 100644 --- a/packages/jest-transform/src/ScriptTransformer.ts +++ b/packages/jest-transform/src/ScriptTransformer.ts @@ -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;