Gentoo Archives: gentoo-commits

From: Lars Wendler <polynomial-c@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: app-shells/zsh/files/, app-shells/zsh/
Date: Mon, 02 May 2022 08:41:55
Message-Id: 1651480903.d6d64f8fa58bae8d750bade521d5354507c9c483.polynomial-c@gentoo
1 commit: d6d64f8fa58bae8d750bade521d5354507c9c483
2 Author: Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
3 AuthorDate: Mon May 2 08:36:59 2022 +0000
4 Commit: Lars Wendler <polynomial-c <AT> gentoo <DOT> org>
5 CommitDate: Mon May 2 08:41:43 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d6d64f8f
7
8 app-shells/zsh: Revbump to fix performance regression
9
10 which was introduced with previous regression fix.
11
12 Closes: https://bugs.gentoo.org/839900
13 Signed-off-by: Lars Wendler <polynomial-c <AT> gentoo.org>
14
15 .../zsh-5.8.1-performance_regression_fix.patch | 139 +++++++++++++++++++++
16 .../{zsh-5.8.1-r1.ebuild => zsh-5.8.1-r2.ebuild} | 1 +
17 2 files changed, 140 insertions(+)
18
19 diff --git a/app-shells/zsh/files/zsh-5.8.1-performance_regression_fix.patch b/app-shells/zsh/files/zsh-5.8.1-performance_regression_fix.patch
20 new file mode 100644
21 index 000000000000..14a3f38eb96d
22 --- /dev/null
23 +++ b/app-shells/zsh/files/zsh-5.8.1-performance_regression_fix.patch
24 @@ -0,0 +1,139 @@
25 +From cbe8d2bcdc20682464217856aa48628804637f28 Mon Sep 17 00:00:00 2001
26 +From: Bart Schaefer <schaefer@×××.org>
27 +Date: Thu, 28 Apr 2022 21:06:51 -0700
28 +Subject: [PATCH] 50133: use read-ahead and lseek-rewind for efficient
29 + line-buffered input
30 +
31 +---
32 + ChangeLog | 6 ++++++
33 + Src/input.c | 24 ++++++++++++++++++++-
34 + configure.ac | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++
35 + 3 files changed, 88 insertions(+), 1 deletion(-)
36 +
37 +diff --git a/ChangeLog b/ChangeLog
38 +index cae2fc4e3..79c77741b 100644
39 +--- a/ChangeLog
40 ++++ b/ChangeLog
41 +@@ -1,3 +1,9 @@
42 ++2022-04-28 Bart Schaefer <schaefer@×××.org>
43 ++
44 ++ * 50133 (Bart, PWS, Jun-ichi): Src/input.c, configure.ac: when
45 ++ lseek(2) is available, use it to check for and rewind read-ahead
46 ++ for more efficient line-buffered input.
47 ++
48 + 2022-03-03 Peter Stephenson <p.w.stephenson@××××××××.com>
49 +
50 + * 49792: Src/input.c, Test/A01grammar.ztst: Use line buffering
51 +diff --git a/Src/input.c b/Src/input.c
52 +index caa8e23b0..6cc1b8a51 100644
53 +--- a/Src/input.c
54 ++++ b/Src/input.c
55 +@@ -217,12 +217,34 @@ shinbufrestore(void)
56 + static int
57 + shingetchar(void)
58 + {
59 +- int nread;
60 ++ int nread, rsize = isset(SHINSTDIN) ? 1 : SHINBUFSIZE;
61 +
62 + if (shinbufptr < shinbufendptr)
63 + return STOUC(*shinbufptr++);
64 +
65 + shinbufreset();
66 ++#ifdef USE_LSEEK
67 ++ if (rsize == 1 && lseek(SHIN, 0, SEEK_CUR) != (off_t)-1)
68 ++ rsize = SHINBUFSIZE;
69 ++ if (rsize > 1) {
70 ++ do {
71 ++ errno = 0;
72 ++ nread = read(SHIN, shinbuffer, rsize);
73 ++ } while (nread < 0 && errno == EINTR);
74 ++ if (nread <= 0)
75 ++ return -1;
76 ++ if (isset(SHINSTDIN) &&
77 ++ (shinbufendptr = memchr(shinbuffer, '\n', nread))) {
78 ++ shinbufendptr++;
79 ++ rsize = (shinbufendptr - shinbuffer);
80 ++ if (nread > rsize &&
81 ++ lseek(SHIN, -(nread - rsize), SEEK_CUR) < 0)
82 ++ zerr("lseek(%d, %d): %e", SHIN, -(nread - rsize), errno);
83 ++ } else
84 ++ shinbufendptr = shinbuffer + nread;
85 ++ return STOUC(*shinbufptr++);
86 ++ }
87 ++#endif
88 + for (;;) {
89 + errno = 0;
90 + nread = read(SHIN, shinbufendptr, 1);
91 +diff --git a/configure.ac b/configure.ac
92 +index af8c5bba8..42f2837cd 100644
93 +--- a/configure.ac
94 ++++ b/configure.ac
95 +@@ -2304,6 +2304,65 @@ if test x$zsh_cv_sys_fifo = xyes; then
96 + AC_DEFINE(HAVE_FIFOS)
97 + fi
98 +
99 ++dnl -----------
100 ++dnl check that lseek() correctly reports seekability.
101 ++dnl -----------
102 ++AC_CACHE_CHECK(if lseek() correctly reports seekability,
103 ++zsh_cv_sys_lseek,
104 ++[AC_RUN_IFELSE([AC_LANG_SOURCE([[
105 ++#include <stdio.h>
106 ++#include <sys/types.h>
107 ++#include <fcntl.h>
108 ++#include <unistd.h>
109 ++#include <sys/socket.h>
110 ++#include <sys/stat.h>
111 ++int main() {
112 ++ int pipefd[2], fd;
113 ++ off_t ret;
114 ++ char* tmpfile = "seekfiletest.tmp";
115 ++ if ((fd = open(tmpfile, O_CREAT, S_IRUSR)) < 0) {
116 ++ fprintf(stderr, "creating file failed\n");
117 ++ return 1;
118 ++ }
119 ++ ret = lseek(fd, 0, SEEK_CUR);
120 ++ close(fd);
121 ++ unlink(tmpfile);
122 ++ if (ret == (off_t)-1) {
123 ++ fprintf(stderr, "lseek on regular file failed\n");
124 ++ return 1;
125 ++ }
126 ++ if (pipe(pipefd) < 0) {
127 ++ fprintf(stderr, "creating pipe failed\n");
128 ++ return 1;
129 ++ }
130 ++ write(pipefd[1], "abcdefgh", 8);
131 ++ ret = lseek(pipefd[0], 0, SEEK_CUR);
132 ++ close(pipefd[0]);
133 ++ close(pipefd[1]);
134 ++ if (ret != (off_t)-1) {
135 ++ fprintf(stderr, "lseek on pipe succeeded\n");
136 ++ return 1;
137 ++ }
138 ++ if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
139 ++ fprintf(stderr, "creating UNIX domain socket failed\n");
140 ++ return 1;
141 ++ }
142 ++ ret = lseek(fd, 0, SEEK_CUR);
143 ++ close(fd);
144 ++ if (ret != (off_t)-1) {
145 ++ fprintf(stderr, "lseek on UNIX domain socket succeeded\n");
146 ++ return 1;
147 ++ }
148 ++ return 0;
149 ++}
150 ++]])],[zsh_cv_sys_lseek=yes],[zsh_cv_sys_lseek=no],[zsh_cv_sys_lseek=yes])
151 ++])
152 ++AH_TEMPLATE([USE_LSEEK],
153 ++[Define to 1 if lseek() can be used for SHIN.])
154 ++if test x$zsh_cv_sys_lseek = xyes; then
155 ++ AC_DEFINE(USE_LSEEK)
156 ++fi
157 ++
158 + dnl -----------
159 + dnl test for whether link() works
160 + dnl for instance, BeOS R4.51 doesn't support hard links yet
161 +--
162 +2.36.0
163 +
164
165 diff --git a/app-shells/zsh/zsh-5.8.1-r1.ebuild b/app-shells/zsh/zsh-5.8.1-r2.ebuild
166 similarity index 98%
167 rename from app-shells/zsh/zsh-5.8.1-r1.ebuild
168 rename to app-shells/zsh/zsh-5.8.1-r2.ebuild
169 index 6cbf8622fe20..dbb80d5ae6d8 100644
170 --- a/app-shells/zsh/zsh-5.8.1-r1.ebuild
171 +++ b/app-shells/zsh/zsh-5.8.1-r2.ebuild
172 @@ -53,6 +53,7 @@ fi
173
174 PATCHES=(
175 "${FILESDIR}/${P}-non_interactive_shell_regression_fix.patch"
176 + "${FILESDIR}/${P}-performance_regression_fix.patch" #839900
177 )
178
179 src_prepare() {