snprintf.c hammering memset()

From: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Mateusz Guzik <mjguzik(at)gmail(dot)com>
Subject: snprintf.c hammering memset()
Date: 2018-10-01 23:09:15
Message-ID: CAEepm=3VF=PUp2f8gU8fgZB22yPE_KBS0+e1AHAtQ=09schTHg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello hackers,

Mateusz Guzik was benchmarking PostgreSQL on FreeBSD investigating the
kqueue thread and complained off-list about a lot of calls to memset()
of size 256KB from dopr() in our snprintf.c code.

Yeah, that says:

PrintfArgType argtypes[NL_ARGMAX + 2];
...
MemSet(argtypes, 0, sizeof(argtypes));

PrintfArgType is an enum, and we define NL_ARGMAX as 16 if the OS
didn't already define it. On FreeBSD 11, NL_ARGMAX was defined as 99
in <limits.h>. On FreeBSD 12, it is defined as 65536... ouch. On a
Debian box I see it is 4096.

Is there any reason to use the OS definition here?

--
Thomas Munro
http://www.enterprisedb.com

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2018-10-01 23:31:31 Re: has_column_privilege behavior (was Re: Assert failed in snprintf.c)
Previous Message Thomas Munro 2018-10-01 22:47:48 Re: SerializeParamList vs machines with strict alignment