delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2017/03/20/22:56:37

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:references
:mime-version:content-type:in-reply-to; q=dns; s=default; b=f74X
KM0GbLGYKYFipcrOcNhIJE8PVomT8kKx9o9LdF019Co0exb1DdVfhI/DgD3Z1ist
qSmg7aSFNikJF++IGjtE3bh1bMV5BBpfHqiUsmbx++QsdXo5ETJTqVZAg+9UIDei
UDwVkuQKB46O07kdoW0PwNIjW8y311FLV7xW1fg=
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:references
:mime-version:content-type:in-reply-to; s=default; bh=gL/AvRFNwY
Nd0oIMzDatUwkZKE8=; b=D3V+sKxw6Kt98l8lXPXmzrEVvsPo9G3bbI4QkmxLYq
MXW+5jWZrXQjnjKW5kYd6CZZjLNZoodvF3JnnytfQKzOY/L9jVbI6V8oEkSLwwZR
5StcBmhrcjOU3sRiFSRM0b0ZRuV6Ity+TlzPLSebmCLLpJDEsjgpOqPBwFAYn57G
E=
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.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 spammy=cease, 2.7.0, ipch, wait.h
X-HELO: mail-pf0-f169.google.com
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=rZml/O+BgNUOUDRKiS44TuzFv+hGX9ggxbrU9R8Ek+I=; b=Qkp1DDZOpFTK3Nh1NPDYaC+WDdhPe52I/lneUiUWyMpqJuA7H0EJeiiObH8rG53P3j dBh9rVmfqaG8XIsh0FaaRW8lTkhz2JVKH9F1Ao2VaGafWJ8uUJI7rit/zvbvy9DnrTYe EpTrI1d0qfyqifrJNxngJAmVr6uk2x8cqDBmB/Xr7vV/7Syw2C1zILbBODUQG+UB25OD Cv7v9+nQHojrJ7uPWMZDpvCQ5kShXxqRPbPQTCeGHW2tIb+gUVFa6rv469mA4ykG9DgT KFz/1johQKJJCGITDM2urZkSZpNRqlafhqfKI+OzKjcSby/M1/vgXoNoV5ZLOQWQLUQ9 UUPA==
X-Gm-Message-State: AFeK/H0hkNwJOLQ2e95AG+aI5/0BhcBtRONfkopPvD/NHHkzerncETvvrSia3tfGQun4jg==
X-Received: by 10.98.81.132 with SMTP id f126mr8673048pfb.25.1490064978120; Mon, 20 Mar 2017 19:56:18 -0700 (PDT)
Date: Tue, 21 Mar 2017 02:56:14 +0000
From: Noah Misch <noah AT leadboat DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: cygserver - Postgres Multiple connection Load Testing - Inifinte Loop
Message-ID: <20170321025614.GA2100214@tornado.leadboat.com>
References: <200408030333 DOT i733XEXn023894 AT mx3 DOT redhat DOT com> <20040803100612 DOT GP31522 AT cygbert DOT vinschen DOT de>
MIME-Version: 1.0
In-Reply-To: <20040803100612.GP31522@cygbert.vinschen.de>
User-Agent: Mutt/1.5.24 (2015-08-30)

--1yeeQ81UyVL57Vl7
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Tue, Aug 03, 2004 at 12:06:12PM +0200, Corinna Vinschen wrote:
> On Aug  2 20:33, sarbx-cygwin6344 AT mailblocks DOT com wrote:
> > This time around, cygserver does not eat CPU. But after 5 to 6 
> > concurrent
> > connections nothing seem to work, looks kind of hung. There is no 
> > activity in the Postgres
> > log file. Opening a new database connection also hangs. There is no 
> > activity on the machine.

> Any chance to create a simple testcase which uncovers that behaviour
> without involving a whole database system?

Attached test program reproduces it on Cygwin 2.7.0, Cygwin 1.7.5, and a few
intermediate versions.  The program creates sixteen processes that each
perform a tight loop over the following:

- select one of four semaphores
- reduce semaphore's value from 1 to 0 ("lock" it)
- raise semaphore's value from 0 to 1 ("unlock" it)

On GNU/Linux, AIX, and Solaris, the processes keep busy and finish one million
lock/unlock cycles apiece in a few minutes.  On Cygwin, they hang within a few
seconds and under one hundred cycles apiece.  At that point, cygserver is
unresponsive to other clients; for example, "strace /bin/true", opening a new
Cygwin terminal, "cat /proc/sysvipc/sem" and "cygserver -S" all hang.  In most
tests, cygserver was not consuming CPU while unresponsive.

Thanks,
nm

--1yeeQ81UyVL57Vl7
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="sema_parallel.c"

/*
 * Demonstrate cygserver hang under concurrent sysv semaphore traffic.  Run
 * without arguments.  Output will cease within a few seconds, and cygserver
 * will be unresponsive to all clients.
 *
 * This is compatible with default cygserver settings; it uses a single
 * semaphore set of four semaphores.
 */

#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>

#define SEM_KEY 0x631a2c3e
#define N_WORKER 16
#define N_SEMA (N_WORKER/4)
#define N_CYCLE 1000000

union semun
{
    int val;
    struct semid_ds *buf;
    unsigned short *array;
};

static int print_every = 1;


/* In parallel, N_WORKER processes run this function. */
static int do_worker(int ordinal, int set)
{
    int i;
    struct sembuf op;

    printf("start worker %d\n", ordinal);
    fflush(stdout);

    op.sem_flg = 0;
    for (i = 1; i <= N_CYCLE; i++)
    {
	op.sem_num = random() % N_SEMA;

	op.sem_op = -1;
	if (0 > semop(set, &op, 1))
	{
	    perror("semop");
	    return 1;
	}

	op.sem_op = 1;
	if (0 > semop(set, &op, 1))
	{
	    perror("semop");
	    return 1;
	}

	if (i % print_every == 0)
	{
	    printf("worker %d: %d cycles elapsed\n", ordinal, i);
	    fflush(stdout);
	}
    }

    return 0;
}

int main(int argc, char **argv)
{
    int status = 1, set, i, child_status;

    if (argc == 2)
	print_every = atoi(argv[1]);
    else if (argc != 1)
    {
	fprintf(stderr, "Usage: sema_parallel [print-every-N]\n");
	return status;
    }

    puts("semget");
    fflush(stdout);
    set = semget(SEM_KEY, N_SEMA, IPC_CREAT | 0600);
    if (set == -1)
    {
	perror("semget");
	return status;
    }

    puts("SETVAL");
    fflush(stdout);
    for (i = 0; i < N_SEMA; i++)
    {
	union semun s;
	s.val = 1;

	if (0 > semctl(set, i, SETVAL, s))
	{
	    perror("semctl(SETVAL)");
	    goto cleanup;
	}
    }

    for (i = 0; i < N_WORKER; i++)
    {
	pid_t pid;
	pid = fork();
	switch (pid)
	{
	    case -1:
		perror("fork");
		goto cleanup;
	    case 0:
		return do_worker(i, set);
	}
    }

    status = 0;

cleanup:
    while (wait(&child_status) != -1)
	;
    if (errno != ECHILD)
    {
	perror("wait");
	status = 1;
    }

    if (0 > semctl(set, 0, IPC_RMID))
    {
	perror("semtctl(IPC_RMID)");
	status = 1;
    }

    return status;
}


--1yeeQ81UyVL57Vl7
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
--1yeeQ81UyVL57Vl7--

- Raw text -


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