Re: Terminate the idle sessions - Mailing list pgsql-hackers

From Li Japin
Subject Re: Terminate the idle sessions
Date
Msg-id 0EFE4882-BC7C-4246-815C-4779BB40E450@hotmail.com
Whole thread Raw
In response to Re: Terminate the idle sessions  (Thomas Munro <thomas.munro@gmail.com>)
Responses RE: Terminate the idle sessions
List pgsql-hackers

> On Aug 31, 2020, at 11:43 AM, Thomas Munro <thomas.munro@gmail.com> wrote:
> 
> On Mon, Aug 31, 2020 at 2:40 PM Li Japin <japinli@hotmail.com> wrote:
>> Could you give the more details about the test instructions?
> 
> Hi Japin,
> 
> Sure.  Because I wasn't trying to get reliable TPS number or anything,
> I just used a simple short read-only test with one connection, like
> this:
> 
> pgbench -i -s10 postgres
> pgbench -T60 -Mprepared -S postgres
> 
> Then I looked for the active backend and ran strace -c -p XXX for a
> few seconds and hit ^C to get the counters.  I doubt the times are
> very accurate, but the number of calls is informative.
> 
> If you do that on a server running with -c statement_timeout=10s, you
> see one setitimer() per transaction.  If you also use -c
> idle_session_timeout=10s at the same time, you see two.

Hi, Thomas,

Thanks for your point out this problem, here is the comparison.

Without Optimize settimer usage:
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 41.22    1.444851           1   1317033           setitimer
 28.41    0.995936           2    658622           sendto
 24.63    0.863316           1    659116       599 recvfrom
  5.71    0.200275           2    111055           pread64
  0.03    0.001152           2       599           epoll_wait
  0.00    0.000000           0         1           epoll_ctl
------ ----------- ----------- --------- --------- ----------------
100.00    3.505530               2746426       599 total

With Optimize settimer usage:
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 49.89    1.464332           1   1091429           sendto
 40.83    1.198389           1   1091539       219 recvfrom
  9.26    0.271890           1    183321           pread64
  0.02    0.000482           2       214           epoll_wait
  0.00    0.000013           3         5           setitimer
  0.00    0.000010           2         5           rt_sigreturn
  0.00    0.000000           0         1           epoll_ctl
------ ----------- ----------- --------- --------- ----------------
100.00    2.935116               2366514       219 total

Here’s a modified version of Thomas’s patch.


Attachment

pgsql-hackers by date:

Previous
From: Yugo NAGATA
Date:
Subject: Re: Implementing Incremental View Maintenance
Next
From: Thomas Munro
Date:
Subject: Re: Hybrid Hash/Nested Loop joins and caching results from subplans