Re: Make printtup a bit faster

2024-09-12 Thread Andy Fan
MAX_INTERVAL_PRECISION, true); *cp = '\0'; } @@ -4665,16 +4666,16 @@ EncodeInterval(struct pg_itm *itm, int style, char *str) } else if (has_day) { - sprintf(cp, "%lld %lld:%02d:", - (long long) mday, (long long) hour, min); - cp += strlen(cp);

Re: Make printtup a bit faster

2024-09-10 Thread Tom Lane
Andy Fan writes: > Just to be clearer, I'd like work on the out function only due to my > internal assignment. (Since David planned it for PG18, so it is better > say things clearer eariler). I'd put parts of out(print) function > refactor in the next 2 days. I think it deserves a double check bef

Re: Make printtup a bit faster

2024-09-10 Thread Andy Fan
Hello David & Andreas, > On 8/29/24 1:51 PM, David Rowley wrote: >> I had planned to work on this for PG18, but I'd be happy for some >> assistance if you're willing. > > I am interested in working on this, unless Andy Fan wants to do this > work. :) I believe that optimizing the out, in and se

Re: Make printtup a bit faster

2024-09-01 Thread Andy Fan
Andy Fan writes: > The attached is PoC of this idea, not matter which method are adopted > (rewrite all the outfunction or a optional print function), I think the > benefit will be similar. In the blew test case, it shows us 10%+ > improvements. (0.134ms vs 0.110ms) After working on more {type}_

Re: Make printtup a bit faster

2024-08-30 Thread Andreas Karlsson
On 8/29/24 1:51 PM, David Rowley wrote: I had planned to work on this for PG18, but I'd be happy for some assistance if you're willing. I am interested in working on this, unless Andy Fan wants to do this work. :) I believe that optimizing the out, in and send functions would be worth the pai

Re: Make printtup a bit faster

2024-08-29 Thread Andy Fan
David Rowley writes: > On Fri, 30 Aug 2024 at 03:33, Tom Lane wrote: >> >> David Rowley writes: >> > [ redesign I/O function APIs ] >> > I had planned to work on this for PG18, but I'd be happy for some >> > assistance if you're willing. >> >> I'm skeptical that such a thing will ever be practi

Re: Make printtup a bit faster

2024-08-29 Thread Andy Fan
David Rowley writes: > On Fri, 30 Aug 2024 at 13:04, Andy Fan wrote: >> >> David Rowley writes: >> > If there's anywhere we call output functions >> > where the resulting value isn't directly appended to a StringInfo, >> > then we could just use a temporary StringInfo to obtain the cstring >> >

Re: Make printtup a bit faster

2024-08-29 Thread David Rowley
On Fri, 30 Aug 2024 at 13:04, Andy Fan wrote: > > David Rowley writes: > > If there's anywhere we call output functions > > where the resulting value isn't directly appended to a StringInfo, > > then we could just use a temporary StringInfo to obtain the cstring > > and its length. > > I think th

Re: Make printtup a bit faster

2024-08-29 Thread Andy Fan
David Rowley writes: > On Fri, 30 Aug 2024 at 12:10, Andy Fan wrote: >> What would be the extra benefit we redesign all the out functions? > > If I've understood your proposal correctly, it sounds like you want to > invent a new "print" output function for each type to output the Datum > onto a

Re: Make printtup a bit faster

2024-08-29 Thread David Rowley
On Fri, 30 Aug 2024 at 12:10, Andy Fan wrote: > What would be the extra benefit we redesign all the out functions? If I've understood your proposal correctly, it sounds like you want to invent a new "print" output function for each type to output the Datum onto a StringInfo, if that's the case, w

Re: Make printtup a bit faster

2024-08-29 Thread David Rowley
On Fri, 30 Aug 2024 at 03:33, Tom Lane wrote: > > David Rowley writes: > > [ redesign I/O function APIs ] > > I had planned to work on this for PG18, but I'd be happy for some > > assistance if you're willing. > > I'm skeptical that such a thing will ever be practical. To avoid > breaking un-con

Re: Make printtup a bit faster

2024-08-29 Thread Andy Fan
David Rowley writes: Hello David, >> My high level proposal is define a type specific print function like: >> >> oidprint(Datum datum, StringInfo buf) >> textprint(Datum datum, StringInfo buf) > > I think what we should do instead is make the output functions take a > StringInfo and just pass it

Re: Make printtup a bit faster

2024-08-29 Thread Tom Lane
David Rowley writes: > [ redesign I/O function APIs ] > I had planned to work on this for PG18, but I'd be happy for some > assistance if you're willing. I'm skeptical that such a thing will ever be practical. To avoid breaking un-converted data types, all the call sites would have to support bo

Re: Make printtup a bit faster

2024-08-29 Thread David Rowley
On Thu, 29 Aug 2024 at 21:40, Andy Fan wrote: > > > Usually I see printtup in the perf-report with a noticeable ratio. > Part of the slowness is caused by "memcpy", "strlen" and palloc in > outfunction. Yeah, it's a pretty inefficient API from a performance point of view. > My high level propos

Make printtup a bit faster

2024-08-29 Thread Andy Fan
Usually I see printtup in the perf-report with a noticeable ratio. Take "SELECT * FROM pg_class" for example, we can see: 85.65% 3.25% postgres postgres [.] printtup The high level design of printtup is: 1. Used a pre-allocated StringInfo DR_printtup.buf to store data for each tuples.