Re: snprintf.c hammering memset()

2018-10-01 Thread Tom Lane
Andres Freund writes: > On 2018-10-01 20:19:16 -0400, Tom Lane wrote: >> That patch takes the memset out of the main line, but it'd still be >> a performance problem for formats using argument reordering; and the >> stack-space concern would remain the same. > What I mean is that it shouldn't be

Re: snprintf.c hammering memset()

2018-10-01 Thread Andres Freund
Hi, On 2018-10-01 17:46:55 -0700, Andres Freund wrote: > On 2018-10-01 20:19:16 -0400, Tom Lane wrote: > > argtypes is only a small part of the stack-space issue, there's also > > argvalues which is (at least) twice as big. I don't think second-guessing > > the compiler about the most efficient r

Re: snprintf.c hammering memset()

2018-10-01 Thread Andres Freund
Hi, On 2018-10-01 20:19:16 -0400, Tom Lane wrote: > Andres Freund writes: > > On 2018-10-01 19:52:40 -0400, Tom Lane wrote: > >> Ouch indeed. Quite aside from cycles wasted, that's way more stack than > >> we want this to consume. I'm good with forcing this to 16 or so ... > >> any objections?

Re: snprintf.c hammering memset()

2018-10-01 Thread Tom Lane
Thomas Munro writes: > 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 . On FreeBSD 12, it is defined as 65536... ouch. On a > Debian box I see it is 4096. Some further research: * My Red Hat boxes a

Re: snprintf.c hammering memset()

2018-10-01 Thread Tom Lane
Andres Freund writes: > On 2018-10-01 19:52:40 -0400, Tom Lane wrote: >> Ouch indeed. Quite aside from cycles wasted, that's way more stack than >> we want this to consume. I'm good with forcing this to 16 or so ... >> any objections? > Especially after your performance patch, shouldn't we actu

Re: snprintf.c hammering memset()

2018-10-01 Thread Andres Freund
Hi, On 2018-10-01 19:52:40 -0400, Tom Lane wrote: > Thomas Munro writes: > > 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 sa

Re: snprintf.c hammering memset()

2018-10-01 Thread Tom Lane
Thomas Munro writes: > 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]; > ... > Me

snprintf.c hammering memset()

2018-10-01 Thread Thomas Munro
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, s