Re: pgbench small bug fix - Mailing list pgsql-hackers

From Fabien COELHO
Subject Re: pgbench small bug fix
Date
Msg-id alpine.DEB.2.10.1603032018170.24239@sto
Whole thread Raw
In response to Re: pgbench small bug fix  (Aleksander Alekseev <a.alekseev@postgrespro.ru>)
Responses Re: pgbench small bug fix
List pgsql-hackers
Hello Aleksander,

Thanks for the look at the patch.

>> time pgbench -T 5 -R 0.1 -P 1 -c 2 -j 2
>
> On my laptop this command executes 25 seconds instead of 5.
> I'm pretty sure it IS a bug. Probably a minor one though.

Sure.

> [...] you should probably write:
>
> if(someint > 0)

Ok.

> if(somebool == TRUE)

I like "if (somebool)", the "== TRUE" looks like a tautology, and the 
short version is also the current practice in the project.

> Also I suggest to introduce a few new boolean variables with meaningful
> names instead of writing all these long expressions right inside of
> if( ... ).

I agree about the lisibility, but there are semantics issues to consider:
    if (short-A && pretty-long-B)

If short-A is false then pretty-long-B is not evaluated, which is a win 
because it also costs, I try to order conditions... If I move 
pretty-long-B before then the cost is always paid. Now I could write:
    if (short-A) {      bool b = pretty-long-B;      if (b) {        ...

But this looks contrived and people would raise other questions about such
a strange construct for implementing && in 3 lines, 2 if and 1 variable...

> As a side note I noticed that pgbench.c is not pgindent'ed. Since you
> are modifying this file anyway probably you cold solve this issue too?
> As a separate patch perhaps.

As Robert said, not the purpose of this patch.

Attached is a v3 which test integers more logically. I'm a lazy programmer 
who tends to minimize the number of key strokes.

-- 
Fabien.

pgsql-hackers by date:

Previous
From: Alexander Korotkov
Date:
Subject: Re: improving GROUP BY estimation
Next
From: Thomas Munro
Date:
Subject: Re: Support for N synchronous standby servers - take 2