On Thu, 2019-05-23 at 17:22 -0300, Andreas Hasenack wrote: > Hi, > > I'm updating the autofs version in Ubuntu from 5.1.2 to 5.1.5, and as > part of that process was looking over the patches we are carrying. I > found this one: > Author: Joel Ebel <jbebel@xxxxxxxxxx> > Bug-Ubuntu: https://launchpad.net/bugs/591100 > Description: Increase group buffer size geometrically rather than > linearly when its found to be small. > . > This prevents package to eat the cpu if you have large groups. > > --- a/lib/mounts.c > +++ b/lib/mounts.c > @@ -1245,7 +1245,7 @@ > status = getgrgid_r(gid, pgr, gr_tmp, tmplen, ppgr); > if (status != ERANGE) > break; > - tmplen += grplen; > + tmplen *= 2; > } > > if (status || !pgr) { > > That came from https://bugs.launchpad.net/ubuntu/+source/autofs5/+bug/591100, > and the intention is to speed up the scenario where a user belongs to > thousands of groups. grplen is 1024, and looping over getgrgid_r() > hundreds of times took a while of high CPU usage. > > The patch doesn't apply cleanly anymore, but the tmplen+=grplen code > is still there. Would upstream be interested in adopting this change, > or something like it? Sure, I've added the patch below to my patch queue, it will get committed at some point. You might also be interested in checking if anything at https://mirrors.edge.kernel.org/pub/linux/daemons/autofs/v5/patches-5.1.6/ might be needed. I have more patches, I'll post them for review on the autofs list before committing them, some of those might be of interest to you too. If you run into problems ask here and I'll try and help out. autofs-5.1.5 - Increase group buffer size geometrically From: Joel Ebel <jbebel@xxxxxxxxxx> Increase group buffer size geometrically rather than linearly when its found to be small. This prevents package to eat the cpu if you have large groups. --- lib/mounts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mounts.c b/lib/mounts.c index e4092d2f..5a8e8cdb 100644 --- a/lib/mounts.c +++ b/lib/mounts.c @@ -1539,7 +1539,7 @@ void set_tsd_user_vars(unsigned int logopt, uid_t uid, gid_t gid) status = getgrgid_r(gid, pgr, gr_tmp, tmplen, ppgr); if (status != ERANGE) break; - tmplen += grplen; + tmplen *= 2; /* Don't tempt glibc to alloca() larger than is (likely) * available on the stack if limit-getgrgid-size is enabled.