pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedScript which shows performance of ByteA: ascii vs binary
7+ messages / 5 participants
[nested] [flat]
* Script which shows performance of ByteA: ascii vs binary
@ 2019-03-22 10:23 Thomas Güttler <guettliml@thomas-guettler.de>
0 siblings, 1 reply; 7+ messages in thread
From: Thomas Güttler @ 2019-03-22 10:23 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org; adrian.klaver@aklaver.com; hjp-pgsql@hjp.at; tgl@sss.pgh.pa.us
Thank you for asking several times for a benchmark.
I wrote it now and it is visible: inserting random bytes into bytea is much slower,
if you use the psycopg2 defaults.
Here is the chart:
https://github.com/guettli/misc/blob/master/bench-bytea-inserts-postrgres.png
And here is the script which creates the chart:
https://github.com/guettli/misc/blob/master/bench-bytea-inserts-postrgres.py
Please let me know if there is something wrong or could get improved.
Regards,
Thomas Güttler
Am 18.03.19 um 15:33 schrieb Thomas Güttler:
> I did some benchmarking and in my setup there was major
> performance difference.
>
> I tested a ByteA column.
>
> If I used ascii data the tests took 52 seconds.
> If I used random binary data the test took 250 seconds.
>
> binary data is (roughly) five times slower than ascii data?
>
> Is this a know fact, or is there something wrong with my benchmark?
>
> I used Python and psycopg2.
>
> Regards,
> Thomas Güttler
>
>
--
Thomas Guettler http://www.thomas-guettler.de/
I am looking for feedback: https://github.com/guettli/programming-guidelines
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Script which shows performance of ByteA: ascii vs binary
@ 2019-03-22 12:40 Francisco Olarte <folarte@peoplecall.com>
parent: Thomas Güttler <guettliml@thomas-guettler.de>
0 siblings, 3 replies; 7+ messages in thread
From: Francisco Olarte @ 2019-03-22 12:40 UTC (permalink / raw)
To: Thomas Güttler <guettliml@thomas-guettler.de>; +Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>; Adrian Klaver <adrian.klaver@aklaver.com>; Peter J. Holzer <hjp-pgsql@hjp.at>; Tom Lane <tgl@sss.pgh.pa.us>
Thomas:
On Fri, Mar 22, 2019 at 11:22 AM Thomas Güttler
<guettliml@thomas-guettler.de> wrote:
> Thank you for asking several times for a benchmark.
> I wrote it now and it is visible: inserting random bytes into bytea is much slower,
> if you use the psycopg2 defaults.
> Here is the chart:
> https://github.com/guettli/misc/blob/master/bench-bytea-inserts-postrgres.png
> And here is the script which creates the chart:
> https://github.com/guettli/misc/blob/master/bench-bytea-inserts-postrgres.py
I'm not too sure, but I read ( in the code ) you are measuring a
nearly not compressible urandom data againtst a highly compressible (
'x'*i ) data,
are you sure the difference is not due to data being compressed and
generating much less disk usage in toast-tables/wal?
Francisco Olarte.
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Script which shows performance of ByteA: ascii vs binary
@ 2019-03-22 12:48 Kenneth Marshall <ktm@rice.edu>
parent: Francisco Olarte <folarte@peoplecall.com>
2 siblings, 0 replies; 7+ messages in thread
From: Kenneth Marshall @ 2019-03-22 12:48 UTC (permalink / raw)
To: Francisco Olarte <folarte@peoplecall.com>; +Cc: Thomas Güttler <guettliml@thomas-guettler.de>; pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>; Adrian Klaver <adrian.klaver@aklaver.com>; Peter J. Holzer <hjp-pgsql@hjp.at>; Tom Lane <tgl@sss.pgh.pa.us>
On Fri, Mar 22, 2019 at 01:40:28PM +0100, Francisco Olarte wrote:
> Thomas:
>
> On Fri, Mar 22, 2019 at 11:22 AM Thomas Güttler
> <guettliml@thomas-guettler.de> wrote:
> > Thank you for asking several times for a benchmark.
> > I wrote it now and it is visible: inserting random bytes into bytea is much slower,
> > if you use the psycopg2 defaults.
> > Here is the chart:
> > https://github.com/guettli/misc/blob/master/bench-bytea-inserts-postrgres.png
> > And here is the script which creates the chart:
> > https://github.com/guettli/misc/blob/master/bench-bytea-inserts-postrgres.py
>
> I'm not too sure, but I read ( in the code ) you are measuring a
> nearly not compressible urandom data againtst a highly compressible (
> 'x'*i ) data,
> are you sure the difference is not due to data being compressed and
> generating much less disk usage in toast-tables/wal?
>
> Francisco Olarte.
>
+1
Regards,
Ken
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Script which shows performance of ByteA: ascii vs binary
@ 2019-03-22 13:04 Thomas Güttler <guettliml@thomas-guettler.de>
parent: Francisco Olarte <folarte@peoplecall.com>
2 siblings, 2 replies; 7+ messages in thread
From: Thomas Güttler @ 2019-03-22 13:04 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
Am 22.03.19 um 13:40 schrieb Francisco Olarte:
> Thomas:
>
> On Fri, Mar 22, 2019 at 11:22 AM Thomas Güttler
> <guettliml@thomas-guettler.de> wrote:
>> Thank you for asking several times for a benchmark.
>> I wrote it now and it is visible: inserting random bytes into bytea is much slower,
>> if you use the psycopg2 defaults.
>> Here is the chart:
>> https://github.com/guettli/misc/blob/master/bench-bytea-inserts-postrgres.png
>> And here is the script which creates the chart:
>> https://github.com/guettli/misc/blob/master/bench-bytea-inserts-postrgres.py
>
> I'm not too sure, but I read ( in the code ) you are measuring a
> nearly not compressible urandom data againtst a highly compressible (
> 'x'*i ) data,
> are you sure the difference is not due to data being compressed and
> generating much less disk usage in toast-tables/wal?
+1
for this case toast-tables/wal is a detail of the implementation.
This tests does not care about the "why it takes longer". It just generates
a performance chart.
Yes, it does exactly what you say: it compares
nearly not compressible urandom data against a highly compressible data.
In my case, will get nearly random data (binary PDF, JPG, ...). And that's why
I wanted to benchmark it.
Regards,
Thomas
--
Thomas Guettler http://www.thomas-guettler.de/
I am looking for feedback: https://github.com/guettli/programming-guidelines
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Script which shows performance of ByteA: ascii vs binary
@ 2019-03-22 14:48 Adrian Klaver <adrian.klaver@aklaver.com>
parent: Thomas Güttler <guettliml@thomas-guettler.de>
1 sibling, 0 replies; 7+ messages in thread
From: Adrian Klaver @ 2019-03-22 14:48 UTC (permalink / raw)
To: Thomas Güttler <guettliml@thomas-guettler.de>; pgsql-general@lists.postgresql.org
On 3/22/19 6:04 AM, Thomas Güttler wrote:
>
>
> Am 22.03.19 um 13:40 schrieb Francisco Olarte:
>> Thomas:
>>
>> On Fri, Mar 22, 2019 at 11:22 AM Thomas Güttler
>> <guettliml@thomas-guettler.de> wrote:
>>> Thank you for asking several times for a benchmark.
>>> I wrote it now and it is visible: inserting random bytes into bytea
>>> is much slower,
>>> if you use the psycopg2 defaults.
>>> Here is the chart:
>>>
>>> https://github.com/guettli/misc/blob/master/bench-bytea-inserts-postrgres.png
>>>
>>> And here is the script which creates the chart:
>>>
>>> https://github.com/guettli/misc/blob/master/bench-bytea-inserts-postrgres.py
>>>
>>
>> I'm not too sure, but I read ( in the code ) you are measuring a
>> nearly not compressible urandom data againtst a highly compressible (
>> 'x'*i ) data,
>> are you sure the difference is not due to data being compressed and
>> generating much less disk usage in toast-tables/wal?
>
> +1
>
> for this case toast-tables/wal is a detail of the implementation.
> This tests does not care about the "why it takes longer". It just generates
> a performance chart.
TOAST is tunable, might want to take a look at:
https://www.postgresql.org/docs/11/storage-toast.html
>
> Yes, it does exactly what you say: it compares
> nearly not compressible urandom data against a highly compressible data.
>
> In my case, will get nearly random data (binary PDF, JPG, ...). And
> that's why
> I wanted to benchmark it.
>
> Regards,
> Thomas
>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Script which shows performance of ByteA: ascii vs binary
@ 2019-03-22 17:37 Francisco Olarte <folarte@peoplecall.com>
parent: Thomas Güttler <guettliml@thomas-guettler.de>
1 sibling, 0 replies; 7+ messages in thread
From: Francisco Olarte @ 2019-03-22 17:37 UTC (permalink / raw)
To: Thomas Güttler <guettliml@thomas-guettler.de>; +Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Thomas:
On Fri, Mar 22, 2019 at 2:03 PM Thomas Güttler
<guettliml@thomas-guettler.de> wrote:
> > I'm not too sure, but I read ( in the code ) you are measuring a
> > nearly not compressible urandom data againtst a highly compressible (
...
> for this case toast-tables/wal is a detail of the implementation.
> This tests does not care about the "why it takes longer". It just generates
> a performance chart.
> Yes, it does exactly what you say: it compares
> nearly not compressible urandom data against a highly compressible data.
> In my case, will get nearly random data (binary PDF, JPG, ...). And that's why
> I wanted to benchmark it.
Well, if all you wanted is to benchmark, a performance chart, you know
it. I assumed you wanted to know more, like where the bottleneck is
and how to try to avoid it. My fault.
I was specifically confused because, IIRC, you said ascii data took
much longer than binary, which is a completely different test ( you
can test ascii vs binary by generating
chunks of random numbers in say, the 0 to 127 and sending that data
once as is and once more shifting left by one every byte. That should
test ascii-binary differences, but
if you test random vs uniform I think the problem is in the
randomness, you could just test sending '\x92'*i, or something
similar, but if you are just interested in the benchmark, you have it
done.
Just one thing, a single graph with two labels "ascii" and "random" is
misleading, as constant/random is orthogonal with ascii/binary, but as
I said, my fault, all the text about psycopg and other stuff led me to
think you wanted some kind of diagnosis and improvements.
Regards.
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Script which shows performance of ByteA: ascii vs binary
@ 2019-03-22 19:55 Peter J. Holzer <hjp-pgsql@hjp.at>
parent: Francisco Olarte <folarte@peoplecall.com>
2 siblings, 0 replies; 7+ messages in thread
From: Peter J. Holzer @ 2019-03-22 19:55 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 2019-03-22 13:40:28 +0100, Francisco Olarte wrote:
> On Fri, Mar 22, 2019 at 11:22 AM Thomas Güttler
> <guettliml@thomas-guettler.de> wrote:
> > Thank you for asking several times for a benchmark.
> > I wrote it now and it is visible: inserting random bytes into bytea
> > is much slower, if you use the psycopg2 defaults.
> > Here is the chart:
> > https://github.com/guettli/misc/blob/master/bench-bytea-inserts-postrgres.png
> > And here is the script which creates the chart:
> > https://github.com/guettli/misc/blob/master/bench-bytea-inserts-postrgres.py
>
> I'm not too sure, but I read ( in the code ) you are measuring a
> nearly not compressible urandom data againtst a highly compressible (
> 'x'*i ) data,
Yes, that seems to be the main difference. My "ascii" test creates
random data in the range [32, 126], which is not very compressible, and
I didn't see much of a difference to the full range (10th percentile and
median were the same, 90th percentile was noticeably better). If I
create "random" data in the range [120, 120], I also get a large speedup
(about 3.5 times). Interestingly the difference vanishes for large (> 10
MB) blobs.
> are you sure the difference is not due to data being compressed and
> generating much less disk usage in toast-tables/wal?
Yes, I think that's it: He is basically measuring how fast his CPU
can compress a stream of constant bytes. Not very meaningful.
Another difference I noticed between our benchmarks is that I used a
plain bytes object while he used a psycopg2.Binary object. Those might
be serialized differently, but since the speed difference is adequately
explained by the (lack of) randomness, I am not going to investigate
this.
hp
--
_ | Peter J. Holzer | we build much bigger, better disasters now
|_|_) | | because we have much more sophisticated
| | | hjp@hjp.at | management tools.
__/ | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/;
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2019-03-22 19:55 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-03-22 10:23 Script which shows performance of ByteA: ascii vs binary Thomas Güttler <guettliml@thomas-guettler.de>
2019-03-22 12:40 ` Francisco Olarte <folarte@peoplecall.com>
2019-03-22 12:48 ` Kenneth Marshall <ktm@rice.edu>
2019-03-22 13:04 ` Thomas Güttler <guettliml@thomas-guettler.de>
2019-03-22 14:48 ` Adrian Klaver <adrian.klaver@aklaver.com>
2019-03-22 17:37 ` Francisco Olarte <folarte@peoplecall.com>
2019-03-22 19:55 ` Peter J. Holzer <hjp-pgsql@hjp.at>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox