pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Fabien COELHO <coelho@cri.ensmp.fr>
To: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Cc: PostgreSQL Developers <pgsql-hackers@postgresql.org>
Subject: Re: PATCH: pgbench - merging transaction logs
Date: Sat, 2 May 2015 09:30:37 -0400 (AST)
Message-ID: <alpine.DEB.2.10.1505020916130.8161@sto> (raw)
In-Reply-To: <5519F65F.7040005@2ndquadrant.com>
References: <54FCB11B.5050907@2ndquadrant.com>
	<alpine.DEB.2.10.1503150945070.4015@sto>
	<5505CF30.7030308@2ndquadrant.com>
	<alpine.DEB.2.10.1503151935160.4015@sto>
	<CA+TgmoZAuB+ZfMhS-LSjqsyv=gA7kBjADWf_A34cUeVTrNUmVA@mail.gmail.com>
	<alpine.DEB.2.10.1503171614580.31431@sto>
	<CA+TgmoZ8eFnFeg14bhWYstRdODLHa+f+zDtPjAweOgmPkLcUww@mail.gmail.com>
	<alpine.DEB.2.10.1503201327170.12124@sto>
	<550CCBE5.8060009@2ndquadrant.com>
	<alpine.DEB.2.10.1503281016080.17117@sto>
	<551730E9.108@2ndquadrant.com>
	<alpine.DEB.2.10.1503291003160.17117@sto>
	<5519F65F.7040005@2ndquadrant.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-hackers>


Hello,

>> The counters are updated when the transaction is finished anyway?
>
> Yes, but the thread does not know it's time to write the results until
> it completes the first transaction after the interval ends ...
>
> Let's say the very first query in thread #1 takes a minute for some
> reason, while the other threads process 100 transactions per second. So
> before the thread #1 can report 0 transactions for the first second, the
> other threads already have results for the 60 intervals.
>
> I think there's no way to make this work except for somehow tracking
> timestamp of the last submitted results for each thread, and only
> flushing results older than the minimum of the timestamps. But that's
> not trivial - it certainly is more complicated than just writing into a
> shared file descriptor.

I agree that such an approach this would be horrible for a very limited 
value. However I was suggesting that a transaction is counted only when it 
is finished, so the aggregated data is to be understood as refering to 
"finished transactions in the interval", and what is in progress would be 
counted in the next interval anyway.

> Merging results for each transaction would not have this issue, but it
> would also use the lock much more frequently, and that seems like a
> pretty bad idea (especially for the workloads with short transactions
> that you suggested are bad match for detailed log - this would make the
> aggregated log bad too).
>
> Also notice that with all the threads will try to merge the data (and
> thus acquire the lock) at almost the same time - this is especially true
> for very short transactions. I would be surprised if this did not cause
> issues on read-only workloads with large numbers of threads.

ISTM that the aggregated version should fare better than the detailed log,
whatever is done: the key performance issue is because fprintf is slow, 
with aggregated log these are infrequent, and only arithmetic remains in a 
critical section.

>>>> (2) The feature would not be available for the thread-emulation with
>>>> this approach, but I do not see this as a particular issue as I
>>>> think that it is pretty much only dead code and a maintenance burden.
>>>
>>> I'm not willing to investigate that, nor am I willing to implement
>>> another feature that works only sometimes (I've done that in the past,
>>> and I find it a bad practice).
>
> [...]

After the small discussion I triggered, I've submitted a patch to drop 
thread fork-emulation from pgbench.

> [...]
> Also, if the lock for the shared buffer is cheaper than the lock
> required for fprintf, it may still be an improvement.

Yep. "fprintf" does a lot of processing, so it is the main issue.

-- 
Fabien.


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (31+ messages)  latest in thread

Message-ID: <alpine.DEB.2.10.1505020916130.8161@sto>
Permalink:  ../alpine.DEB.2.10.1505020916130.8161@sto/
Also on:    postgresql.org/message-id/alpine.DEB.2.10.1505020916130.8161@sto

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: coelho@cri.ensmp.fr, tomas.vondra@2ndquadrant.com
  Subject: Re: PATCH: pgbench - merging transaction logs
  In-Reply-To: <alpine.DEB.2.10.1505020916130.8161@sto>

* 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