From: | David Rowley <dgrowleyml(at)gmail(dot)com> |
---|---|
To: | Heikki Linnakangas <hlinnaka(at)iki(dot)fi> |
Cc: | Melih Mutlu <m(dot)melihmutlu(at)gmail(dot)com>, Andrew Dunstan <andrew(at)dunslane(dot)net>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Speed up JSON escape processing with SIMD plus other optimisations |
Date: | 2024-08-03 14:11:18 |
Message-ID: | CAApHDvptffkvmUVqx2ULMyZGoMsbt2B8b5op5hwBk2pZudzjdw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Thu, 1 Aug 2024 at 16:15, David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
> I'm pretty happy with this now so I'd like to commit this and move on
> to other work. Doing "#define ESCAPE_JSON_MAX_LOOKHEAD 512", seems
> like the right thing. If anyone else wants to verify my results or
> take a look at the patch, please do so.
I did some more testing on this on a few different machines; apple M2
Ultra, AMD 7945HX and with a Raspberry Pi 4.
I've attached the results as graphs with the master time normalised to
1. I tried out quite a few different values for flushing the buffer,
256 bytes in powers of 2 up to 8192 bytes. It seems like each machine
has its own preference to what this should be set to, but no machine
seems to be too picky about the exact value. They're all small enough
values to fit in L1d cache on each of the CPUs. Test 4 shouldn't
change much as there's no SIMD going on in that test. You might notice
a bit of noise from all machines for test 4, apart from the M2. You
can assume a similar level of noise for tests 1 to 3 on each of the
machines. The Raspberry Pi does seem to prefer not flushing the
buffer until the end (listed as "patched" in the graphs). I suspect
that's because that CPU does better with less code. I've not taken
these results quite as seriously since it's likely a platform that we
wouldn't want to prefer when it comes to tuning optimisations. I was
mostly interested in not seeing regressions.
I think, if nobody else thinks differently, I'll rename
ESCAPE_JSON_MAX_LOOKHEAD to ESCAPE_JSON_FLUSH_AFTER and set it to 512.
The exact value does not seem to matter too much and 512 seems fine.
It's better for the M2 than the 7945HX, but not by much.
I've also attached the script I ran to get these results and also the
full results.
David
Attachment | Content-Type | Size |
---|---|---|
json_simd_results.txt | text/plain | 5.7 KB |
![]() |
image/png | 59.1 KB |
![]() |
image/png | 64.6 KB |
![]() |
image/png | 61.7 KB |
json_bench.sh.txt | text/plain | 1.5 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Melanie Plageman | 2024-08-03 15:14:20 | Re: Draft release notes for next week's releases are up |
Previous Message | Heikki Linnakangas | 2024-08-03 14:07:46 | Re: Fix inappropriate uses of atol() |