Re: Hitting X limit in launching maximum number of vkcube instances

52 views
Skip to first unread message

Adam Jackson

unread,
May 5, 2023, 5:55:28 PM5/5/23
to Anuj Phogat, ofou...@redhat.com, xorg-...@lists.x.org
No, just MAXCLIENTS. Probably vkcube (or the driver it's using) should fail more robustly when it can't connect to the display, instead of letting you render without presenting though.

On Fri, May 5, 2023 at 5:28 PM Anuj Phogat <anuj....@gmail.com> wrote:
Hi All,

I've been trying to run the maximum number of instances of vkcube (Vulkan application)
in Ubuntu 22.04. I'm hitting one of these X errors when I get past ~256 instances:
- "Maximum number of clients reached"
- "_XSERVTransSocketUNIXAccept: accept() failed"

I was able to get past these errors by adding below code in xorg conf file passed to Xorg
using '-config' option:
Section "ServerFlags"
    Option "MaxClients" "512"
EndSection

Now I'm not seeing X errors about the limit but X windows past the 256 limit don't render
anything. Do I need to adjust any other limits (other than MAXCLIENTS) to make instances
past 256 limit render as expected ? I would appreciate any pointers to help me debug and
resolve this issue.

Adding Adam and Olivier in Cc as I noticed a few old patches from them around changing
MAXCLIENTS.

Thanks
Anuj

Anuj Phogat

unread,
May 6, 2023, 6:34:47 AM5/6/23
to Adam Jackson, ofou...@redhat.com, xorg-...@lists.x.org
Thanks for the quick response Adam. I've seen this behavior across multiple graphics applications
and graphics drivers. This is an extreme use case I'm trying out. So, there's a possibility of this use
case not being handled correctly by any of the applications or graphics drivers.
But I also see some basic X functionality, like closing the window using the "x" button, not working
properly with windows opened past the 256 limit. This happens with a modified limit of 512. I had to
use xkill to close those windows. Any thoughts about this?

Thanks
Anuj 

Anuj Phogat

unread,
May 6, 2023, 6:34:47 AM5/6/23
to xorg-...@lists.x.org, ofou...@redhat.com, Adam Jackson

Alan Coopersmith

unread,
May 6, 2023, 12:04:24 PM5/6/23
to Anuj Phogat, Adam Jackson, ofou...@redhat.com, xorg-...@lists.x.org
On 5/5/23 16:07, Anuj Phogat wrote:
> Thanks for the quick response Adam. I've seen this behavior across multiple
> graphics applications
> and graphics drivers. This is an extreme use case I'm trying out. So, there's a
> possibility of this use
> case not being handled correctly by any of the applications or graphics drivers.
> But I also see some basic X functionality, like closing the window using the "x"
> button, not working
> properly with windows opened past the 256 limit. This happens with a modified
> limit of 512. I had to
> use xkill to close those windows. Any thoughts about this?

Closing the window with the "x" button is a function of the window manager.
Does the window manager you are using assume the number of X clients is
limited to 256? That xkill works suggests the X server is handling it
correctly.

--
-Alan Coopersmith- alan.coo...@oracle.com
Oracle Solaris Engineering - https://blogs.oracle.com/solaris

Adam Jackson

unread,
May 17, 2023, 11:36:15 AM5/17/23
to Anuj Phogat, xorg-...@lists.x.org
I would start by figuring out exactly why accept() is failing. You could use strace for this, or a patch like:


Note that to make that patch work you need to patch libxtrans and then rebuild xserver against the result, xtrans is a header-only library.

- ajax

On Tue, May 16, 2023 at 7:21 PM Anuj Phogat <anuj....@gmail.com> wrote:
On Sat, May 6, 2023 at 9:04 AM Alan Coopersmith
<alan.coo...@oracle.com> wrote:
>
> On 5/5/23 16:07, Anuj Phogat wrote:
> > Thanks for the quick response Adam. I've seen this behavior across multiple
> > graphics applications
> > and graphics drivers. This is an extreme use case I'm trying out. So, there's a
> > possibility of this use
> > case not being handled correctly by any of the applications or graphics drivers.
> > But I also see some basic X functionality, like closing the window using the "x"
> > button, not working
> > properly with windows opened past the 256 limit. This happens with a modified
> > limit of 512. I had to
> > use xkill to close those windows. Any thoughts about this?
>
> Closing the window with the "x" button is a function of the window manager.
> Does the window manager you are using assume the number of X clients is
> limited to 256?  That xkill works suggests the X server is handling it
> correctly.
Alan, I took the window manager out of the equation by running multiple
instances of vkcube with Xorg without running any window manager.
Xorg.0.log file does show a log about set max clients through a .conf file:
(**) Option "MaxClients" "512"

But, I start seeing below error messages at the end of the log file once
the number of vkcube instances go past 256:
"_XSERVTransSocketUNIXAccept: accept() failed"

Seems like the modified max clients limit of 512 is not getting configured
correctly in X.

What can I do to fix / debug this error ?

Anuj Phogat

unread,
May 18, 2023, 4:44:58 AM5/18/23
to Alan Coopersmith, xorg-...@lists.x.org, Adam Jackson
On Sat, May 6, 2023 at 9:04 AM Alan Coopersmith
<alan.coo...@oracle.com> wrote:
>
> On 5/5/23 16:07, Anuj Phogat wrote:
> > Thanks for the quick response Adam. I've seen this behavior across multiple
> > graphics applications
> > and graphics drivers. This is an extreme use case I'm trying out. So, there's a
> > possibility of this use
> > case not being handled correctly by any of the applications or graphics drivers.
> > But I also see some basic X functionality, like closing the window using the "x"
> > button, not working
> > properly with windows opened past the 256 limit. This happens with a modified
> > limit of 512. I had to
> > use xkill to close those windows. Any thoughts about this?
>
> Closing the window with the "x" button is a function of the window manager.
> Does the window manager you are using assume the number of X clients is
> limited to 256? That xkill works suggests the X server is handling it
> correctly.
Alan, I took the window manager out of the equation by running multiple
instances of vkcube with Xorg without running any window manager.
Xorg.0.log file does show a log about set max clients through a .conf file:
(**) Option "MaxClients" "512"

But, I start seeing below error messages at the end of the log file once
the number of vkcube instances go past 256:
"_XSERVTransSocketUNIXAccept: accept() failed"

Seems like the modified max clients limit of 512 is not getting configured
correctly in X.

What can I do to fix / debug this error ?


>

Olivier Fourdan

unread,
May 23, 2023, 4:48:14 AM5/23/23
to Anuj Phogat, xorg-...@lists.x.org, Adam Jackson
Hi
I didn't find a mention of the actual version of the Xserver you're
running (not knowing what Ubuntu ships), but this may be relevant for
your issue:

https://gitlab.freedesktop.org/xorg/xserver/-/issues/1310

Fixed with:

https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/937

And backported to the 21.1 branch with:

https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/953

HTH

Cheers

Olivier

Olivier Fourdan

unread,
Aug 16, 2023, 3:47:02 AM8/16/23
to Anuj Phogat, xorg-...@lists.x.org, Adam Jackson
Hi Anuj,

On Mon, Aug 14, 2023 at 8:27 PM Anuj Phogat <anuj....@gmail.com> wrote:
- I'm still getting the "_XSERVTransSocketUNIXAccept: accept() failed" error
after launching ~ 256 instances of vkcube. I was able to find the root
cause of error after patching libxtrans based on Adam's suggestion:
"_XSERVTransSocketUNIXAccept: accept() failed (Too many open files)"
- Based on the hint from the error string, I changed the system wide limit to
increase the maximum number of open files allowed from default 1024 to
'ulimit -n' confirmed the new limit. But, this change doesn't change
the error past launching ~ 256 instances of vkcube.
- I hit the same error but at ~330 instances when I try to run glxgears.

Questions:
What am I missing when changing the open files limit ?

Make sure the X process has inherited that limit, depending on how/where you bumped the limit, the X server process may not have that applied.

You can check using the /proc filesystem on Linux:

$ cat /proc/$(pidof Xorg)/limits

What else can I try to get past this error ?

If you can get 330 instances of glxgears, it means that you are already past the 256 limit, hence the maxclients worked.

It is worth noting that the limit applies to all X11 clients, so if you run a window manager, an xterm, etc, everything counts.

Also if a client opens more than one connection to the X server, that also counts. So you can expect that a limit of 512 might give you a lower actual limit.
 
Should I reopen xserver issue [1] or create a new issue to track it ?

I doubt that this is an X server issue.

FWIW, I just tried here with Xwayland rootful and was able to run 474 instances of vkcube on a rootful stanlone Xwayland instance:

$ Xwayland -maxclients 512 -decorate :12 7
$ for i in $(seq 1 512); do DISPLAY=:12 vkcube& done
$ ps aux | grep vkcube | wc -l
474

I have seen some "Maximum number of clients reached" errors while the vkcube instances were spawning en masse, so I suspect maybe the vulkan implementation is opening a connection to the display for some reason temporarily, so having those start all at once may lead to a lower actual limit of clients..

To confirm that theory, I dedid the same test waiting a bit between each instance of vkcube.

And nowI can reach the limit of 512:

$ for i in $(seq 1 512); do DISPLAY=:12 vkcube; sleep .2 & done
$ ps aux | grep vkcube | wc -l
512

So yeah, no bug in the Xserver AFAICS.
 
This is with:

$ cat /proc/$(pidof Xwayland)/limits
Limit                     Soft Limit           Hard Limit           Units    
Max cpu time              unlimited            unlimited            seconds  
Max file size             unlimited            unlimited            bytes    
Max data size             unlimited            unlimited            bytes    
Max stack size            8388608              unlimited            bytes    
Max core file size        unlimited            unlimited            bytes    
Max resident set          unlimited            unlimited            bytes    
Max processes             62319                62319                processes
Max open files            16777216             16777216             files    
Max locked memory         8388608              8388608              bytes    
Max address space         unlimited            unlimited            bytes    
Max file locks            unlimited            unlimited            locks    
Max pending signals       62319                62319                signals  
Max msgqueue size         819200               819200               bytes    
Max nice priority         0                    0                    
Max realtime priority     0                    0                    
Max realtime timeout      unlimited            unlimited            us       

[1] : https://gitlab.freedesktop.org/xorg/xserver/-/issues/1310

Cheers
Olivier

 

Anuj Phogat

unread,
Aug 16, 2023, 3:55:48 AM8/16/23
to Olivier Fourdan, xorg-...@lists.x.org, Adam Jackson
Hi Olivier, Adam

My apologies for the delayed response. I was pulled into something more
urgent. Listing down my findings after experimentation based on your
suggestions:

- I was earlier using x server version 1.21.1.4. I recently upgraded the version
to 1.21.1.8. This upgrade fixed issues (dead windows and rendering) with
launching kcalc instances past the 256 default max client limit. I tested
launching 300 kcalc instances.
- I'm still getting the "_XSERVTransSocketUNIXAccept: accept() failed" error
after launching ~ 256 instances of vkcube. I was able to find the root
cause of error after patching libxtrans based on Adam's suggestion:
"_XSERVTransSocketUNIXAccept: accept() failed (Too many open files)"
- Based on the hint from the error string, I changed the system wide limit to
increase the maximum number of open files allowed from default 1024 to
'ulimit -n' confirmed the new limit. But, this change doesn't change
the error past launching ~ 256 instances of vkcube.
- I hit the same error but at ~330 instances when I try to run glxgears.

Questions:
What am I missing when changing the open files limit ?
What else can I try to get past this error ?
Should I reopen xserver issue [1] or create a new issue to track it ?

[1] : https://gitlab.freedesktop.org/xorg/xserver/-/issues/1310


Thanks
Anuj

Anuj Phogat

unread,
Aug 17, 2023, 4:25:30 AM8/17/23
to Olivier Fourdan, xorg-...@lists.x.org, Adam Jackson
Hi Olivier,

Thanks for experimenting on your end to rule out any X server issues.
I was able to match your results and launch 512 instances of vkcube
after making sure that Xserver (1.21.1.8) has inherited the higher
"max open files" limit. I really appreciate help from you, Adam and Alan.

Anuj

Walter Harms

unread,
Aug 24, 2023, 6:39:16 AM8/24/23
to Anuj Phogat, xorg-...@lists.x.org
Hi Anuj,
i did not follow the diskussion in detail, so maybe this was already purposed:
Some years ago in an unrelated project i also hit the max file pointer limit.
The reason seemed obvious but in the end it turned out the be something different.
Did you check you hit the expected limit when reducing the max number of file pointers ?
(This helps also to locate the culprit by checking with lsof).

jm2c.
wh
________________________________________
Von: xorg-devel <xorg-deve...@lists.x.org> im Auftrag von Anuj Phogat <anuj....@gmail.com>
Gesendet: Donnerstag, 17. August 2023 00:01
An: Olivier Fourdan
Cc: xorg-...@lists.x.org; Adam Jackson
Betreff: Re: Hitting X limit in launching maximum number of vkcube instances
Reply all
Reply to author
Forward
0 new messages