snprintf.c hammering memset()
Thomas Munro <thomas.munro@enterprisedb.com>
From: Thomas Munro <thomas.munro@enterprisedb.com>
To: Pg Hackers <pgsql-hackers@postgresql.org>,
Mateusz Guzik <mjguzik@gmail.com>
Date: 2018-10-01T23:09:15Z
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
Commits
-
Set snprintf.c's maximum number of NL arguments to be 31.
- dee848810d8a 9.5.15 landed
- d5895717e000 9.6.11 landed
- a5b46fc66dfb 9.4.20 landed
- a051c19c3cf4 11.0 landed
- 6483381a4d0b 10.6 landed
- 625b38ea0e98 12.0 landed
- 4ed6dc7d4b33 9.3.25 landed