Date: Wed, 08 Nov 2023 19:29:24 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 274968] rpc_clnt_create: The dg_cv variable uses absurdly too much memory Message-ID: <bug-274968-227@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D274968 Bug ID: 274968 Summary: rpc_clnt_create: The dg_cv variable uses absurdly too much memory Product: Base System Version: 14.0-RELEASE Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: asomers@FreeBSD.org The clng_dt_create function allocates global variables named dg_cv and dg_fd_locks, which are then used by the rest of the routines in clnt_dg.c.= =20 They are never freed, and live for the life of the process. These variables are arrays indexed by file descriptor. To ensure that they have enough spa= ce, they are sized according to RLIMIT_NOFILE. The problem is that resource li= mit can be very, very, big. On my production servers, it's autoscaled to 22608= 720. So any process that does _anything_ involving NIS must allocate 259 MiB ju= st for these variables. The exact same mistake is made in clnt_vc.c, with the vc_fd_locks and vc_cv variables. These add up to about 984 MB for every sshd process on my system (I'm not s= ure how 259 gets multiplied to 984, but valgrind --tool=3Dmassif does show that= all the memory is coming from clnt_dg_create). A few hundred of those sshd processes and my entire server falls over. Even with sshd rate limiting, a= bout half of my server's physical RAM is used just for this one stupid array variable. Stupidly, it appears that there's no need for a huge array. Instead, the condvar could've been part of the CLIENT structure. Even stupider, this variable _never_ gets used in some simple applications = like getgrouplist. So we allocate it, fault in every page, and then never use i= t.=20 :facepalm: --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-274968-227>