pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Арсен Арутюнян <arutar@bk.ru>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-general <pgsql-general@postgresql.org>
Subject: Re[4]: LISTEN/NOTIFY ultra slow speed
Date: Tue, 15 Mar 2022 23:48:42 +0300
Message-ID: <1647377322.779959664@f422.i.mail.ru> (raw)
In-Reply-To: <317665.1647354727@sss.pgh.pa.us>
References: <1647262405.342456086@f759.i.mail.ru>
	<1647340764.254194077@f561.i.mail.ru>
	<317665.1647354727@sss.pgh.pa.us>


I decided to rebuild pg 10 first.
I commented out the lines of code with duplicate checking
(/src/backend/commands/async.c)
 
//    if (AsyncExistsPendingNotify(channel, payload))
//        return;
 
and launched this version of pg into production.
This was the only way I could figure out if there was a significant difference in speed. And the results turned out to be very interesting, the query speed increased  by about two times. But unfortunately it's still far from the desired level
 
before the code changes
rmdatabase=# select pg_notify('rmdb_client_message','{"Command":239,"MsgId":"48117898"}');
Время: 974,119 мс
rmdatabase=# select pg_notify('rmdb_client_message','{"Command":239,"MsgId":"48117898"}');
Время: 859,855 мс
rmdatabase=# select pg_notify('rmdb_client_message','{"Command":239,"MsgId":"48117898"}');
Время: 695,741 мс
rmdatabase=# select pg_notify('rmdb_client_message','{"Command":239,"MsgId":"48117898"}');
Время: 77,001 мс
rmdatabase=# select pg_notify('rmdb_client_message','{"Command":239,"MsgId":"48117898"}');
Время: 475,590 мс
rmdatabase=# select pg_notify('rmdb_client_message','{"Command":239,"MsgId":"48117898"}');
Время: 973,449 мс
rmdatabase=# select pg_notify('rmdb_client_message','{"Command":239,"MsgId":"48117898"}');
Время: 1039,825 мс (00:01,040)
rmdatabase=# select pg_notify('rmdb_client_message','{"Command":239,"MsgId":"48117898"}');
Время: 1233,576 мс (00:01,234)
 
 
after the code changes
rmdatabase=# select pg_notify('rmdb_client_message','{"Command":239,"MsgId":"48119697"}');
Время: 431,337 мс
rmdatabase=# select pg_notify('rmdb_client_message','{"Command":239,"MsgId":"48119697"}');
Время: 460,794 мс
rmdatabase=# select pg_notify('rmdb_client_message','{"Command":239,"MsgId":"48119697"}');
Время: 498,042 мс
rmdatabase=# select pg_notify('rmdb_client_message','{"Command":239,"MsgId":"48119697"}');
Время: 604,931 мс
rmdatabase=# select pg_notify('rmdb_client_message','{"Command":239,"MsgId":"48119697"}');
Время: 438,763 мс
rmdatabase=# select pg_notify('rmdb_client_message','{"Command":239,"MsgId":"48119697"}');
Время: 587,827 мс
rmdatabase=# select pg_notify('rmdb_client_message','{"Command":239,"MsgId":"48119697"}');
Время: 621,079 мс
rmdatabase=# select pg_notify('rmdb_client_message','{"Command":239,"MsgId":"48119697"}');
Время: 549,264 мс
rmdatabase=# select pg_notify('rmdb_client_message','{"Command":239,"MsgId":"48119697"}');
Время: 447,218 мс
rmdatabase=# select pg_notify('rmdb_client_message','{"Command":239,"MsgId":"48119697"}');
Время: 526,980 мс
rmdatabase=# select pg_notify('rmdb_client_message','{"Command":239,"MsgId":"48119697"}');
Время: 417,556 мс
 
rmdatabase=# select pg_notify('rmdb_client_message','{"Command":239,"MsgId":"48117898"}');
Время: 185,374 мс
rmdatabase=# select pg_notify('rmdb_client_message','{"Command":239,"MsgId":"48117898"}');
Время: 554,529 мс
rmdatabase=# select pg_notify('rmdb_client_message','{"Command":239,"MsgId":"48117898"}');
Время: 654,769 мс
rmdatabase=# select pg_notify('rmdb_client_message','{"Command":239,"MsgId":"48117898"}');
Время: 577,187 мс
rmdatabase=# select pg_notify('rmdb_client_message','{"Command":239,"MsgId":"48117898"}');
Время: 246,831 мс
rmdatabase=# select pg_notify('rmdb_client_message','{"Command":239,"MsgId":"48117898"}');
 Время: 648,865 мс
 
tomorrow I will deal with the perf
 
--
Arsen Arutyunyan
 
  
>Вторник, 15 марта 2022, 17:32 +03:00 от Tom Lane <tgl@sss.pgh.pa.us>:
> 
>=?UTF-8?B?0JDRgNGB0LXQvSDQkNGA0YPRgtGO0L3Rj9C9?= < arutar@bk.ru > writes:
>> i looked at the file "\src\backend\commands\async.c"
>> there is a check for duplicate messages
>
>Yup.
>
>> Is this slowdown related to this check?
>
>[ shrug... ] You've provided no evidence either for or against that
>possibility.
>
>It seems a little unlikely that you could have a lot of pending messages
>without also seeing data accumulating in pg_notify/, but on the other hand
>it's also hard to think of other places that time could be getting spent
>if the queue is always empty. Can you use perf(1) or some such tool to
>try to identify where the time is being spent? There's some advice
>about that here:
>
>https://wiki.postgresql.org/wiki/Profiling_with_perf
>
>> Is it possible to skip the check if I'm absolutely sure the message is unique?
>
>Not a good idea. You could upgrade to PG 13 or later, where that
>code has been improved.
>
>regards, tom lane
 

Message-ID: <1647377322.779959664@f422.i.mail.ru>
Permalink:  ../1647377322.779959664@f422.i.mail.ru/
Also on:    postgresql.org/message-id/1647377322.779959664@f422.i.mail.ru

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: arutar@bk.ru, tgl@sss.pgh.pa.us
  Subject: Re: LISTEN/NOTIFY ultra slow speed
  In-Reply-To: <1647377322.779959664@f422.i.mail.ru>
  References: <1647262405.342456086@f759.i.mail.ru> <1647340764.254194077@f561.i.mail.ru> <317665.1647354727@sss.pgh.pa.us> <1647377322.779959664@f422.i.mail.ru>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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