From 4851f5d9c448317b2a41cce07a36929a3b6df05d Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 4 Sep 2024 14:59:09 +0200 Subject: [PATCH] msys2-runtime: pipe: Fix a regression that raw_write() slows down This corresponds to https://github.com/msys2/msys2-runtime/pull/227. Signed-off-by: Johannes Schindelin --- ...a-regression-that-raw_write-slows-do.patch | 46 +++++++++++++++++++ msys2-runtime/PKGBUILD | 11 +++-- 2 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 msys2-runtime/0040-Cygwin-pipe-Fix-a-regression-that-raw_write-slows-do.patch diff --git a/msys2-runtime/0040-Cygwin-pipe-Fix-a-regression-that-raw_write-slows-do.patch b/msys2-runtime/0040-Cygwin-pipe-Fix-a-regression-that-raw_write-slows-do.patch new file mode 100644 index 00000000000..6cffbebdc89 --- /dev/null +++ b/msys2-runtime/0040-Cygwin-pipe-Fix-a-regression-that-raw_write-slows-do.patch @@ -0,0 +1,46 @@ +From 2bfb7739dadf6a27f9b4c006adfd69944f3df2f1 Mon Sep 17 00:00:00 2001 +From: Takashi Yano +Date: Sun, 1 Sep 2024 04:31:03 +0900 +Subject: [PATCH 40/N] Cygwin: pipe: Fix a regression that raw_write() slows + down + +After the commit 7f3c22532577, writing to pipe extremely slows down. +This is because cygwait(select_sem, 10, cw_cancel) is called even +when write operation is already completed. With this patch, the +cygwait() is called only if the write operation is not completed. + +Backported-from: 37ab3e0d55 (Cygwin: pipe: Fix a regression that raw_write() slows down, 2024-09-01) +Addresses: https://cygwin.com/pipermail/cygwin/2024-August/256398.html +Fixes: 7f3c22532577 ("Cygwin: pipe: handle signals explicitely in raw_write") +Reported-by: Jim Reisert AD1C +Reviewed-by: Corinna Vinschen +Signed-off-by: Takashi Yano +Signed-off-by: Johannes Schindelin +--- + winsup/cygwin/fhandler/pipe.cc | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/winsup/cygwin/fhandler/pipe.cc b/winsup/cygwin/fhandler/pipe.cc +index 5d2fe12..040176e 100644 +--- a/winsup/cygwin/fhandler/pipe.cc ++++ b/winsup/cygwin/fhandler/pipe.cc +@@ -503,8 +503,9 @@ fhandler_pipe_fifo::raw_write (const void *ptr, size_t len) + raise (SIGPIPE); + goto out; + } +- else +- cygwait (select_sem, 10, cw_cancel); ++ /* Break out on completion */ ++ if (waitret == WAIT_OBJECT_0) ++ break; + /* If we got a timeout in the blocking case, and we already + did a short write, we got a signal in the previous loop. */ + if (waitret == WAIT_TIMEOUT && short_write_once) +@@ -512,6 +513,7 @@ fhandler_pipe_fifo::raw_write (const void *ptr, size_t len) + waitret = WAIT_SIGNALED; + break; + } ++ cygwait (select_sem, 10, cw_cancel); + } + /* Loop in case of blocking write or SA_RESTART */ + while (waitret == WAIT_TIMEOUT || waitret == WAIT_SIGNALED); diff --git a/msys2-runtime/PKGBUILD b/msys2-runtime/PKGBUILD index 67666040239..ba2b64ee2c0 100644 --- a/msys2-runtime/PKGBUILD +++ b/msys2-runtime/PKGBUILD @@ -4,7 +4,7 @@ pkgbase=msys2-runtime pkgname=('msys2-runtime' 'msys2-runtime-devel') pkgver=3.5.4 -pkgrel=1 +pkgrel=2 pkgdesc="Cygwin POSIX emulation engine" arch=('x86_64') url="https://www.cygwin.com/" @@ -67,7 +67,8 @@ source=('msys2-runtime'::git://sourceware.org/git/newlib-cygwin.git#tag=cygwin-$ 0036-build_env-respect-the-MSYS-environment-variable.patch 0037-Revert-Cygwin-Enable-dynamicbase-on-the-Cygwin-DLL-b.patch 0038-Avoid-sharing-cygheaps-across-Cygwin-versions.patch - 0039-uname-report-msys2-runtime-commit-hash-too.patch) + 0039-uname-report-msys2-runtime-commit-hash-too.patch + 0040-Cygwin-pipe-Fix-a-regression-that-raw_write-slows-do.patch) sha256sums=('b8dce32fd9746506752d90ac3f30454fe1689100b08c41442016aaf244cc8584' '9f9e1b6b05cbc9a715fe9443740b25171e9c1a276a058e6ba7e4f6eada6872c8' 'e5b2095e543a5d702cfce6da26cd17a78f40e17620315b1bcc434b94a007ae9b' @@ -107,7 +108,8 @@ sha256sums=('b8dce32fd9746506752d90ac3f30454fe1689100b08c41442016aaf244cc8584' '5990fbc34e4ac09229383e9a0f3326513a5a9482ebcca929302af0707d96a321' 'f74cb189aafc9f8bf04cdad02531d9eca524c2dd12672e4e118bfdbb48926110' '344f108bc9e9ad597e07f1cc8e834e3d1a9fbd9972a1554c1c5de0fce0ae8506' - 'f93578a1150d724a60a7e8eb8491342aeb13f809e2ddb5193d8d126465f665cb') + 'f93578a1150d724a60a7e8eb8491342aeb13f809e2ddb5193d8d126465f665cb' + '41e896036ea67c5d12a712554f4d53949c2dc809bb3545ac6be1fe619848f8af') # Helper macros to help make tasks easier # apply_patch_with_msg() { @@ -183,7 +185,8 @@ prepare() { 0036-build_env-respect-the-MSYS-environment-variable.patch \ 0037-Revert-Cygwin-Enable-dynamicbase-on-the-Cygwin-DLL-b.patch \ 0038-Avoid-sharing-cygheaps-across-Cygwin-versions.patch \ - 0039-uname-report-msys2-runtime-commit-hash-too.patch + 0039-uname-report-msys2-runtime-commit-hash-too.patch \ + 0040-Cygwin-pipe-Fix-a-regression-that-raw_write-slows-do.patch } build() {