Re: pgbench - fix stats when using \sleep

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>, PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pgbench - fix stats when using \sleep
Date: 2016-09-19 20:06:47
Message-ID: 16527898-4a0a-5cb4-4a86-482e5ce981e3@iki.fi
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 08/23/2016 05:47 PM, Fabien COELHO wrote:
> When \sleep is used within a pgbench script it resets txn_scheduled which
> is used for computing stats about the transaction, resulting in absurd
> statistics:
>
> latency average = 0.649 ms *** ??? ***
> ...
> script statistics:
> - statement latencies in milliseconds:
> 0.235 BEGIN;
> 100.301 \sleep 100 ms
> 0.351 END;
>
> I probably created this bug when adding "--rate" in 9.4 and trying to be
> too clever. As nobody complained yet about it, I'm not sure it is worth
> fixing it there, though.
>
> The fix is that "\sleep" does not have to interfere with the txn_scheduled
> field, see the attached patch.
>
> latency average = 100.237 ms *** BETTER ***
> ...
> script statistics:
> - statement latencies in milliseconds:
> 0.099 BEGIN;
> 100.001 \sleep 100 ms
> 0.135 END;

Yep, it's clearly broken. Committed and backpatched down to 9.4. Thanks!

- Heikki

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2016-09-19 20:06:51 Re: Declarative partitioning - another take
Previous Message Robert Haas 2016-09-19 19:50:38 Re: Hash Indexes