delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2016/06/07/08:38:18

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:to:subject:message-id:in-reply-to
:references:mime-version:content-type; q=dns; s=default; b=qrWgT
gBrNP3YZwmKd0hT/X2F639GwKZL7xbX265z4mIu/RCc8z0wsNM5sw8/t5oqLvSTc
WCcpQQSd8SAo4j8b/ICKIMBXFcuX/B7X7PpA4mi3WqUtKNGiWpkdjJo/sJN68IPG
9YKVFP0EWqNhtAOVpKwwTmS3vDiWd8AZhqKToc=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:date:from:to:subject:message-id:in-reply-to
:references:mime-version:content-type; s=default; bh=NxweNIae8Uc
fxlVff5gOTAeHyeo=; b=IJuzyZKGnD4RBXozlJ+TPDV70Svrrt31KiZ8+G07Aog
cxTD/LYK/naCoPNRAW/QL1erqiKFb/9dZMulY8cFJQmJVsa+3wzwJP1mgswqqm7A
9uaXdoDTUywBHHtTAchlMwO4EBfx7zhJg2g0nUr3MAVkisBc/027OKs6UCjLz+vk
=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-1.5 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.2 spammy=Goto, cnt, H*F:D*ne.jp, H*c:HHHH
X-HELO: conuserg-04.nifty.com
DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-04.nifty.com u57CbiPq019820
X-Nifty-SrcIP: [211.133.44.155]
Date: Tue, 7 Jun 2016 21:37:41 +0900
From: Takashi Yano <takashi DOT yano AT nifty DOT ne DOT jp>
To: cygwin AT cygwin DOT com
Subject: Re: Vim responds too slow on the latest snapshot of cygwin1.dll
Message-Id: <20160607213741.4c3fb3486b5f6d70a047bbf3@nifty.ne.jp>
In-Reply-To: <20160606145242.GB4919@calimero.vinschen.de>
References: <20160606003303 DOT ecd888597a40bd1081308452 AT nifty DOT ne DOT jp> <20160606084328 DOT GD14744 AT calimero DOT vinschen DOT de> <20160606200532 DOT c8f2353c277a1957095e69a5 AT nifty DOT ne DOT jp> <CAGHJv4d50OKraNLhF4eicJVR9XQ+_cYizXEiHO=wr8v-aK9k1w AT mail DOT gmail DOT com> <20160606145242 DOT GB4919 AT calimero DOT vinschen DOT de>
Mime-Version: 1.0
X-IsSubscribed: yes

--Multipart=_Tue__7_Jun_2016_21_37_41_+0900_hpxDGZYvbUkuZkDn
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit

Hi Corinna,

I have tested the latest (2016-06-06) snapshot. No problem is found.

I evaluated the response of vim in several environments using a test
case attached. This test case measures the time for
(open a file + scroll up/down 100 times + quit)
in vim.

Results are as follows.

The latest snapshot is the fastest! It's 13% faster than 2.5.1.

You did it!


Machine1: Windows 7 (64bit) + Cygwin 64bit
cygwin 2.5.1         :  1.035133 second
snapshot (2016-05-31): 58.479826 second
snapshot (2016-06-06):  0.898675 second

Machine1: Windows 7 (64bit) + Cygwin 32bit
cygwin 2.5.1         :   1.242907 second
snapshot (2016-05-31):  57.491763 second
snapshot (2016-06-06):   0.911885 second

Machine2: Windows 7 (64bit) + Cygwin 64bit
cygwin 2.5.1         :   0.688432 second
snapshot (2016-05-31): 462.305977 second
snapshot (2016-06-06):   0.596733 second

Machine2: Windows 7 (64bit) + Cygwin 32bit
cygwin 2.5.1         :   0.761117 second
snapshot (2016-05-31): 462.280320 second
snapshot (2016-06-06):   0.660631 second

Machine2: Windows 10 (64bit) + Cygwin 64bit
cygwin 2.5.1         : 0.676545 second
snapshot (2016-05-31): 0.599878 second
snapshot (2016-06-06): 0.599495 second

Machine2: Windows 10 (64bit) + Cygwin 32bit
cygwin 2.5.1         : 0.784049 second
snapshot (2016-05-31): 0.675585 second
snapshot (2016-06-06): 0.675050 second

-- 
Takashi Yano <takashi DOT yano AT nifty DOT ne DOT jp>

--Multipart=_Tue__7_Jun_2016_21_37_41_+0900_hpxDGZYvbUkuZkDn
Content-Type: text/x-csrc;
 name="pty_vim.c"
Content-Disposition: attachment;
 filename="pty_vim.c"
Content-Transfer-Encoding: 7bit

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pty.h>
#include <fcntl.h>
#include <sys/wait.h>
#include <sys/select.h>
#include <sys/ioctl.h>
#include <errno.h>
#include <sys/time.h>
#include <time.h>

int master;
void winsize_set(void)
{
	struct winsize win;
	ioctl(fileno(stdin), TIOCGWINSZ, &win);
	ioctl(master, TIOCSWINSZ, &win);
}

void sig_handler(int sig)
{
	switch (sig) {
	case SIGWINCH:
		winsize_set();
		break;
	case SIGCHLD:
		{
			struct termios tt;
			tcgetattr(fileno(stdout), &tt);
			tt.c_oflag |= OPOST;
			tt.c_lflag |= ECHO|ICANON|ISIG;
			tt.c_iflag |= IXON;
			tcsetattr(fileno(stdout), TCSANOW, &tt);
		}
		/*
		printf("Child Terminated.\n");
		*/
		break;
	}
}

int write_all(int fd, char *buf, int len)
{
	int cnt = 0;
	char *p = buf;
	while (len > cnt) {
		int ret = write(fd, p+cnt, len-cnt);
		if (ret < 0) return ret;
		cnt += ret;
	}
	return cnt;
}

int automate_vim()
{
	int pm, ps;
	pid_t pid;

	if (openpty(&pm, &ps, NULL, NULL, NULL) < 0) {
		perror("openpty()");
		exit(-1);
	}

	master = pm; /* for signal handler */ 

	{ /* Disable echo */
		struct termios tt;
		tcgetattr(ps, &tt);
		tt.c_lflag &= ~ECHO;
		tcsetattr(ps, TCSANOW, &tt);
	}

	pid = fork();
	if (pid<0) {
		perror("fork()");
		close(pm);
		exit(-1);
	}

	if (pid != 0) { /* Parent */
		close(ps);
		{ /* Setup STDIN and STDOUT */
			struct termios tt;

			tcgetattr(fileno(stdout), &tt);
			tt.c_oflag &= ~OPOST;
			tcsetattr(fileno(stdout), TCSANOW, &tt);

			tcgetattr(fileno(stdin), &tt);
			tt.c_lflag &= ~(ECHO|ICANON|ISIG);
			tt.c_iflag &= ~IXON;
			tcsetattr(fileno(stdin), TCSANOW, &tt);
		}

		signal(SIGWINCH, sig_handler);
		signal(SIGCHLD, sig_handler);

		winsize_set();

		{ /* Send commands to vim */
			int i;
			write(pm, "1G", 2); /* Goto first line */
			for (i=0; i<100; i++) {
				write(pm, "\006\002", 2); /* Scroll up and down */
			}
			write(pm, ":q!\n", 4); /* Quit */
		}

		/* Process Input and Output */
		for (;;) {
			fd_set rdfds;
			int nfd;
			int r;

			FD_ZERO(&rdfds);
			FD_SET(pm, &rdfds);
			FD_SET(fileno(stdin), &rdfds);
	
			nfd = ((pm > fileno(stdin))? pm : fileno(stdin) ) + 1;
			r = select(nfd, &rdfds, NULL, NULL, NULL);

			if (r<0 && errno == EINTR) {
				/*
				if ( waitpid(pid, NULL, WNOHANG) == pid) break;
				*/
				continue;
			}
	
			if (r<=0) {
				perror("select()");
				close(pm);
				exit(-1);
			}

			if (r) {
				char buf[BUFSIZ];
				int len;
				if (FD_ISSET(pm, &rdfds)) {
					len = read(pm, buf, BUFSIZ);
					if (len<=0) break;
					if (len > 0) {
						len = write_all(fileno(stdout), buf, len);
						if (len<=0) break;
					}
				}
				if (FD_ISSET(fileno(stdin), &rdfds)) {
					len = read(fileno(stdin), buf, BUFSIZ);
					if (len<=0) break;
					len = write_all(pm, buf, len);
					if (len<=0) break;
				}
			}
		}

		wait(NULL);
		close(pm);
	} else { /* Child */
		close(pm);
		setsid();
		ioctl(ps, TIOCSCTTY, 0);
		dup2(ps, fileno(stdin));
		dup2(ps, fileno(stdout));
		dup2(ps, fileno(stderr));
		close(ps);
		execl("/usr/bin/vim", "vim", "pty_vim.c", NULL);
		perror("execl()");
		exit(-1);
	}
	return 0;
}

int main()
{
	struct timespec tv0, tv1;
	
	clock_gettime(CLOCK_MONOTONIC, &tv0);
	automate_vim();
	clock_gettime(CLOCK_MONOTONIC, &tv1);
	printf("Total: %f second\n",
		(tv1.tv_sec - tv0.tv_sec) + (tv1.tv_nsec - tv0.tv_nsec)*1e-9);
	return 0;
}


--Multipart=_Tue__7_Jun_2016_21_37_41_+0900_hpxDGZYvbUkuZkDn
Content-Type: text/plain; charset=us-ascii

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
--Multipart=_Tue__7_Jun_2016_21_37_41_+0900_hpxDGZYvbUkuZkDn--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019