From: | David Rowley <dgrowleyml(at)gmail(dot)com> |
---|---|
To: | Nathan Bossart <nathandbossart(at)gmail(dot)com> |
Cc: | Joe Conway <mail(at)joeconway(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andrew Dunstan <andrew(at)dunslane(dot)net>, Davin Shearer <davin(at)apache(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: micro-optimizing json.c |
Date: | 2023-12-08 03:11:52 |
Message-ID: | CAApHDvpjoRMrafos6N-Nkja+XSVE_mts7KY85=oy9kwZz-92=g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Fri, 8 Dec 2023 at 12:13, Nathan Bossart <nathandbossart(at)gmail(dot)com> wrote:
> Here's a patch that removes a couple of strlen() calls that showed up
> prominently in perf for a COPY TO (FORMAT json) on 110M integers. On my
> laptop, I see a 20% speedup from ~23.6s to ~18.9s for this test.
+ seplen = use_line_feeds ? sizeof(",\n ") - 1 : sizeof(",") - 1;
Most modern compilers will be fine with just:
seplen = strlen(sep);
I had to go back to clang 3.4.1 and GCC 4.1.2 to see the strlen() call
with that code [1].
With:
if (needsep)
- appendStringInfoString(result, sep);
+ appendBinaryStringInfo(result, sep, seplen);
I might be neater to get rid of the if condition and have:
sep = use_line_feeds ? ",\n " : ",";
seplen = strlen(sep);
slen = 0;
...
for (int i = 0; i < tupdesc->natts; i++)
{
...
appendBinaryStringInfo(result, sep, slen);
slen = seplen;
...
}
David
From | Date | Subject | |
---|---|---|---|
Next Message | Thomas Munro | 2023-12-08 03:17:47 | Re: UBSan pointer overflow in xlogreader.c |
Previous Message | shveta malik | 2023-12-08 03:03:05 | Re: Synchronizing slots from primary to standby |