external/nss/UnpackedTarball_nss.mk | 1 + external/nss/nss.disablefsync.patch | 18 ++++++++++++++++++ sal/osl/unx/file.cxx | 6 +++++- 3 files changed, 24 insertions(+), 1 deletion(-)
New commits: commit c95b1189822bc860ec084e93f5de942d718f6be9 Author: Michael Meeks <michael.me...@collabora.com> AuthorDate: Fri May 10 17:47:19 2024 +0100 Commit: Michael Meeks <michael.me...@collabora.com> CommitDate: Sat Sep 7 11:15:47 2024 +0200 lok: add SAL_DISABLE_FSYNC environment to disable fsync. For state-less containers there is no benefit in fsync'ing, file data is safe when it is up-loaded back to storage - but profiling shows latency from stray fsyncs. Change-Id: I9f03d5866dec05e5507deb56b0dca93b6876225e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167490 Tested-by: Michael Meeks <michael.me...@collabora.com> Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> (cherry picked from commit 90bd45d7a96c8c7084db13e4b6f86753db67655a) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172947 Reviewed-by: Michael Meeks <michael.me...@collabora.com> Tested-by: Jenkins diff --git a/external/nss/UnpackedTarball_nss.mk b/external/nss/UnpackedTarball_nss.mk index 6b69dd9b1631..7a9010bdf743 100644 --- a/external/nss/UnpackedTarball_nss.mk +++ b/external/nss/UnpackedTarball_nss.mk @@ -27,6 +27,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,nss,\ external/nss/nss-restore-manual-pre-dependencies.patch.1 \ external/nss/Wincompatible-function-pointer-types.patch.0 \ $(if $(filter LINUX,$(OS)), \ + external/nss/nss.disablefsync.patch \ external/nss/nss.getrandom.patch) \ $(if $(filter iOS,$(OS)), \ external/nss/nss-ios.patch) \ diff --git a/external/nss/nss.disablefsync.patch b/external/nss/nss.disablefsync.patch new file mode 100644 index 000000000000..8c5d84b553ce --- /dev/null +++ b/external/nss/nss.disablefsync.patch @@ -0,0 +1,18 @@ +--- a/nss/nss/lib/sqlite/sqlite3.c ++++ b/nss/nss/lib/sqlite/sqlite3.c +@@ -36136,6 +36136,15 @@ + static int full_fsync(int fd, int fullSync, int dataOnly){ + int rc; + ++ static int disabledKnown = 0, disabled = 0; ++ if (!disabledKnown) ++ { ++ disabled = getenv("SAL_DISABLE_FSYNC") != NULL; ++ disabledKnown = 1; ++ } ++ if (disabled) ++ return 0; ++ + /* The following "ifdef/elif/else/" block has the same structure as + ** the one below. It is replicated here solely to avoid cluttering + ** up the real code with the UNUSED_PARAMETER() macros. diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx index b15fe963605f..e618a06d373e 100644 --- a/sal/osl/unx/file.cxx +++ b/sal/osl/unx/file.cxx @@ -1236,7 +1236,11 @@ oslFileError SAL_CALL osl_syncFile(oslFileHandle Handle) if (result != osl_File_E_None) return result; - if (fsync(pImpl->m_fd) == -1) + static bool disabled = getenv("SAL_DISABLE_FSYNC") != nullptr; + + if (disabled) + SAL_INFO("sal.file", "fsync(" << pImpl->m_fd << "): Disabled"); + else if (fsync(pImpl->m_fd) == -1) { int e = errno; SAL_INFO("sal.file", "fsync(" << pImpl->m_fd << "): " << UnixErrnoString(e));