Hi

This needs http://patchwork.freedesktop.org/patch/50714/ to be applied on X 
proto first.

Attaching the small programs I use to test this patch, of course the idea is 
tio choose between the number of clients or the number of resources per client 
(as both end up being in the same 29bit value), so both need to be tested.

With these patches I get pretty good results:

First run with 512 clients:

$ ./hw/kdrive/ephyr/Xephyr -maxclients 512 :10
$ DISPLAY=:10 ./countclients 
Maximum number of clients reached => 508 connections created

$ DISPLAY=:10 ./countres 
Resource mask: 0x000fffff
1048575 (0x000fffff) resources created!

Second run with 256 clients:

$ ./hw/kdrive/ephyr/Xephyr -maxclients 256 :10
$ DISPLAY=:10 ./countclients 
Maximum number of clients reached => 255 connections created

$ DISPLAY=:10 ./countres 
Resource mask: 0x001fffff
2097151 (0x001fffff) resources created!

Third run with 128 clients:

$ ./hw/kdrive/ephyr/Xephyr -maxclients 128 :10
$ DISPLAY=:10 ./countclients 
Maximum number of clients reached => 127 connections created

$ DISPLAY=:10 ./countres 
Resource mask: 0x003fffff
4194303 (0x003fffff) resources created!

Forth run with only 64 clients:

$ ./hw/kdrive/ephyr/Xephyr -maxclients 64 :10
$ DISPLAY=:10 ./countclients 
Maximum number of clients reached => 63 connections created

$ DISPLAY=:10 ./countres 
Resource mask: 0x007fffff
8388607 (0x007fffff) resources created!

Cheers,
Olivier
/*
 * Compile with:
 * gcc -g -o countclients countclients.c -lX11
 */


#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/signal.h>
#include <sys/prctl.h>
#include <X11/Xlib.h>
#include <X11/Xlibint.h>

int
main (int argc, char *argv[])
{
    int count = 0;
    char status;

    do
    {
        pid_t pid;
        int fd[2];
        int nbytes;

        pipe (fd);
        if ((pid = fork ()) == -1)
        {
            perror ("fork");
            exit (1);
        }

        if (!pid)
        {
            /* Child */
            Display *dpy;
            Window win;
            XEvent event;
            int first = 1;

            close (fd[0]);
            prctl (PR_SET_PDEATHSIG, SIGTERM);
            dpy = XOpenDisplay (NULL);
            if (!dpy)
            {
                status = 0;     /* Fail */
                write (fd[1], &status, sizeof (char));
                exit (0);
            }

            win = XCreateSimpleWindow (dpy, 
                                       RootWindow (dpy, DefaultScreen (dpy)),
                                       count, count, 50, 50, 10,
                                       WhitePixel (dpy, DefaultScreen (dpy)),
                                       BlackPixel (dpy, DefaultScreen (dpy)));
            XSelectInput (dpy, win, ExposureMask);
            XMapRaised (dpy, win);
            XFlush (dpy);

            for (;;)
            {
                XNextEvent (dpy, &event);
                if (event.type == Expose && first)
                {
                    status = 1; /* Success */
                    write (fd[1], &status, sizeof (char));
                    first = 0;  /* Do it only once to avoid duplicates, you never know */
                }
                /* Loop forvever, we want to keep the connection alive */
            }
            exit (0);
        }
        else
        {
            /* Parent */
            close (fd[1]);
            do
                nbytes = read (fd[0], &status, sizeof (char));
            while (nbytes < sizeof (char));

            if (status)
                count++;
        }
    }
    while (status);

    fprintf (stdout, " => %i connections created\n", count);

    return 0;
}
/*
 * Compile with:
 * gcc -o countres countres.c -lX11
 */

#include <stdio.h>
#include <stdlib.h>
#include <X11/Xlib.h>
#include <X11/Xlibint.h>

static int status = 1;

static int
handleXError (Display * dpy, XErrorEvent * err)
{
    status = 0; /* Fail */
    return 0;
}

int
main (int argc, char *argv[])
{
    Display *display;
    int count = 0;
    int mask;
    XGCValues gcv;
    GC gc;

    display = XOpenDisplay (NULL);
    if (!display)
    {
        fprintf (stderr, "Cannot open display\n");
        return -1;
    }

    XSetErrorHandler (handleXError);

    mask = ((struct _XDisplay *) display)->resource_mask;
    fprintf (stdout, "Resource mask: 0x%0.8lx\n", mask);

    do
    {
        gc = XCreateGC (display, DefaultRootWindow (display), 0L, &gcv);
        XSync (display, 0);
        if (status)
            count++;
    while (status);

    fprintf (stdout, "%i (0x%0.8lx) resources created!\n", count, count);

    return 0;
}
_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to