Lists: | pgsql-hackers |
---|
From: | Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr> |
---|---|
To: | PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Cc: | PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | pgbench - rework variable management |
Date: | 2019-08-13 15:54:31 |
Message-ID: | alpine.DEB.2.21.1908131745380.6526@lancre |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hello pgdevs,
The attached patch improves pgbench variable management as discussed in:
As discussed there as well, the overall effect is small compared to libpq
& system costs when pgbench is talking to a postgres server. When someone
says "pgbench is slow", they really mean "libpq & <my-system> are slow",
because pgbench does not do much beyond jumping from one libpq call to the
next. Anyway, the patch has a measurable positive effect.
###
Rework pgbench variables and associated values for better performance
- a (hopefully) thread-safe symbol table which maps variable names to integers
note that all variables are statically known, but \gset stuff.
- numbers are then used to access per-client arrays
The symbol table stores names as distinct leaves in a tree on bytes.
Each symbol name is the shortest-prefix leaf, possibly including the final
'\0'. Some windows-specific hacks are note tested. File "symbol_table_test.c"
does what it says and can be compiled standalone.
Most malloc/free cycles are taken out of running a benchmark:
- there is a (large?) maximum number of variables of 32*MAX_SCRIPTS
- variable names and string values are statically allocated,
and limited to, 64 bytes
- a per-client persistent buffer is used for various purpose,
to avoid mallocs/frees.
Functions assignVariables & parseQuery basically shared the same variable
substitution logic, but differed in what was substituted. The logic has been
abstracted into a common function.
This patch brings pgbench-specific overheads down on some tests, one
thread one client, on my laptop, with the attached scripts, in tps:
- set_x_1.sql: 11.1M -> 14.2M
- sets.sql: 0.8M -> 2.7M # 20 \set
- set.sql: 1.5M -> 2.0M # 3 \set & "complex" expressions
- empty.sql: 63.9K -> 64.1K (…)
- select_aid.sql: 29.3K -> 29.3K
- select_aids.sql: 23.4K -> 24.2K
- gset_aid.sql: 28.3K -> 29.2K
So we are talking significant improvements on pgbench-only scripts, only
a few percents once pgbench must interact with a CPU-bound server, because
time is spent elsewhere.
--
Fabien.
Attachment | Content-Type | Size |
---|---|---|
empty.sql | application/x-sql | 2 bytes |
select_aids.sql | application/x-sql | 77 bytes |
select_aid.sql | application/x-sql | 70 bytes |
pgbench-symbols-2.patch | text/x-diff | 49.1 KB |
set_x_1.sql | application/x-sql | 9 bytes |
sets.sql | application/x-sql | 212 bytes |
gset_aid.sql | application/x-sql | 64 bytes |
From: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
---|---|
To: | Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr> |
Cc: | PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: pgbench - rework variable management |
Date: | 2019-09-03 00:13:05 |
Message-ID: | CA+hUKG+a+JuAzYPmCmnf2biWxNWjvgptpxcF-dDg-LT06mTC6A@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Wed, Aug 14, 2019 at 3:54 AM Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr> wrote:
> Some windows-specific hacks are note tested.
Somehow this macro hackery has upset the Windows socket headers:
--
Thomas Munro
https://enterprisedb.com
From: | Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr> |
---|---|
To: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
Cc: | PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: pgbench - rework variable management |
Date: | 2019-09-03 04:57:19 |
Message-ID: | alpine.DEB.2.21.1909030640500.7199@lancre |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Lists: | pgsql-hackers |
>> Some windows-specific hacks are note tested.
>
> Somehow this macro hackery has upset the Windows socket headers:
>
> https://ci.appveyor.com/project/postgresql-cfbot/postgresql/build/1.0.55019
I noticed, but I do not have any windows host so I cannot test locally.
The issue is how to do a mutex on Windows, which does not have pthread so
it has to be emulated. I'll try again by sending a blind update to the
patch and see how it goes.
--
Fabien.
From: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
---|---|
To: | Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr> |
Cc: | PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: pgbench - rework variable management |
Date: | 2019-09-03 05:54:21 |
Message-ID: | CA+hUKGL3K25A6td9Wk2k4PghGsopPGK7oJbdOV7riRML6nScrw@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Tue, Sep 3, 2019 at 4:57 PM Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr> wrote:
> I noticed, but I do not have any windows host so I cannot test locally.
>
> The issue is how to do a mutex on Windows, which does not have pthread so
> it has to be emulated. I'll try again by sending a blind update to the
> patch and see how it goes.
If you have the patience and a github account, you can push code onto
a public github branch having also applied the patch mentioned at
https://wiki.postgresql.org/wiki/Continuous_Integration, go to
appveyor.com and tell it to watch your git hub account, and then it'll
build and test every time you push a new tweak. Takes a few minutes
to get the answer each time you try something, but I have managed to
get things working on Windows that way.
--
Thomas Munro
https://enterprisedb.com
From: | Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr> |
---|---|
To: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
Cc: | PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: pgbench - rework variable management |
Date: | 2019-09-03 11:55:15 |
Message-ID: | alpine.DEB.2.21.1909031353180.3362@lancre |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hello Thomas,
>> I noticed, but I do not have any windows host so I cannot test locally.
>>
>> The issue is how to do a mutex on Windows, which does not have pthread so
>> it has to be emulated. I'll try again by sending a blind update to the
>> patch and see how it goes.
>
> If you have the patience and a github account, you can push code onto
> a public github branch having also applied the patch mentioned at
> https://wiki.postgresql.org/wiki/Continuous_Integration, go to
> appveyor.com and tell it to watch your git hub account, and then it'll
> build and test every time you push a new tweak. Takes a few minutes
> to get the answer each time you try something, but I have managed to
> get things working on Windows that way.
Thanks for the tip.
I'll try that if the blind attempt attached version does not work.
--
Fabien.
Attachment | Content-Type | Size |
---|---|---|
pgbench-symbols-3.patch | text/x-diff | 49.3 KB |
From: | Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr> |
---|---|
To: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
Cc: | PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: pgbench - rework variable management |
Date: | 2019-11-06 11:08:03 |
Message-ID: | alpine.DEB.2.21.1911061207300.21586@lancre |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Lists: | pgsql-hackers |
Patch v4 is a just a rebase.
--
Fabien.
Attachment | Content-Type | Size |
---|---|---|
pgbench-symbols-4.patch | text/x-diff | 49.3 KB |
From: | Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr> |
---|---|
To: | Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
Cc: | PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: pgbench - rework variable management |
Date: | 2020-01-09 22:04:28 |
Message-ID: | alpine.DEB.2.21.2001091721530.7789@pseudo |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Lists: | pgsql-hackers |
> Patch v4 is a just a rebase.
Patch v5 is a rebase with some adjustements.
--
Fabien.
Attachment | Content-Type | Size |
---|---|---|
pgbench-symbols-5.patch | text/x-diff | 49.3 KB |
From: | David Steele <david(at)pgmasters(dot)net> |
---|---|
To: | Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr> |
Cc: | PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: pgbench - rework variable management |
Date: | 2020-03-27 16:35:23 |
Message-ID: | [email protected] |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Lists: | pgsql-hackers |
Hi Fabien,
On 1/9/20 5:04 PM, Fabien COELHO wrote:
>
>> Patch v4 is a just a rebase.
>
> Patch v5 is a rebase with some adjustements.
This patch is failing on the Windows build:
https://ci.appveyor.com/project/postgresql-cfbot/postgresql/build/1.0.85698
I'm not sure if this had been fixed in v3 and this is a new issue or if
it has been failing all along. Either way, it should be updated.
Marked Waiting on Author.
BTW -- sorry if I seem to be picking on your patches but these happen to
be the patches with the longest time since any activity.
Regards,
--
-David
david(at)pgmasters(dot)net
From: | Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr> |
---|---|
To: | David Steele <david(at)pgmasters(dot)net> |
Cc: | PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: pgbench - rework variable management |
Date: | 2020-03-27 22:25:58 |
Message-ID: | alpine.DEB.2.21.2003272321370.16227@pseudo |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Lists: | pgsql-hackers |
>> Patch v5 is a rebase with some adjustements.
>
> This patch is failing on the Windows build:
> https://ci.appveyor.com/project/postgresql-cfbot/postgresql/build/1.0.85698
>
> I'm not sure if this had been fixed in v3 and this is a new issue or if it
> has been failing all along. Either way, it should be updated.
I don't do windows, so the mutex stuff for windows is just blind
programming.
> Marked Waiting on Author.
>
> BTW -- sorry if I seem to be picking on your patches but these happen to be
> the patches with the longest time since any activity.
Basically, my areas of interest do not match committers' areas of
interest.
v6 is a yet-again blind attempt at fixing the windows mutex. If someone
with a windows could tell me if it is ok, and if not what to fix, it would
be great.
--
Fabien.
Attachment | Content-Type | Size |
---|---|---|
pgbench-symbols-6.patch | text/x-diff | 49.4 KB |
From: | David Steele <david(at)pgmasters(dot)net> |
---|---|
To: | Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr> |
Cc: | PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: pgbench - rework variable management |
Date: | 2020-03-27 22:42:49 |
Message-ID: | [email protected] |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Lists: | pgsql-hackers |
On 3/27/20 6:25 PM, Fabien COELHO wrote:
>
>>> Patch v5 is a rebase with some adjustements.
>>
>> This patch is failing on the Windows build:
>> https://ci.appveyor.com/project/postgresql-cfbot/postgresql/build/1.0.85698
>>
>>
>> I'm not sure if this had been fixed in v3 and this is a new issue or
>> if it has been failing all along. Either way, it should be updated.
>
> I don't do windows, so the mutex stuff for windows is just blind
> programming.
>
>> Marked Waiting on Author.
>>
>> BTW -- sorry if I seem to be picking on your patches but these happen
>> to be the patches with the longest time since any activity.
>
> Basically, my areas of interest do not match committers' areas of interest.
>
> v6 is a yet-again blind attempt at fixing the windows mutex. If someone
> with a windows could tell me if it is ok, and if not what to fix, it
> would be great.
Regarding Windows testing you may find this thread useful:
--
-David
david(at)pgmasters(dot)net
From: | Michael Paquier <michael(at)paquier(dot)xyz> |
---|---|
To: | David Steele <david(at)pgmasters(dot)net> |
Cc: | Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: pgbench - rework variable management |
Date: | 2020-09-17 05:31:48 |
Message-ID: | [email protected] |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Lists: | pgsql-hackers |
On Fri, Mar 27, 2020 at 06:42:49PM -0400, David Steele wrote:
> Regarding Windows testing you may find this thread useful:
>
> https://www.postgresql.org/message-id/CAMN686ExUKturcWp4POaaVz3gR3hauSGBjOCd0E-Jh1zEXqf_Q%40mail.gmail.com
Since then, the patch is failing to apply. As this got zero activity
for the last six months, I am marking the entry as returned with
feedback in the CF app.
--
Michael
From: | Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr> |
---|---|
To: | Michael Paquier <michael(at)paquier(dot)xyz> |
Cc: | David Steele <david(at)pgmasters(dot)net>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: pgbench - rework variable management |
Date: | 2020-09-19 07:17:31 |
Message-ID: | alpine.DEB.2.22.394.2009190914270.2728660@pseudo |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Lists: | pgsql-hackers |
Bonjour Michaël,
>> https://www.postgresql.org/message-id/CAMN686ExUKturcWp4POaaVz3gR3hauSGBjOCd0E-Jh1zEXqf_Q%40mail.gmail.com
>
> Since then, the patch is failing to apply. As this got zero activity
> for the last six months, I am marking the entry as returned with
> feedback in the CF app.
Hmmm… I did not notice it did not apply anymore. I do not have much time
to contribute much this round and probably the next as well, so fine with
me.
--
Fabien.