Re: pgbench - doCustom cleanup

From: Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: "Jamison, Kirk" <k(dot)jamison(at)jp(dot)fujitsu(dot)com>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pgbench - doCustom cleanup
Date: 2018-11-20 13:41:04
Message-ID: alpine.DEB.2.21.1811201036350.7257@lancre
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Hello Alvaro,

Thanks for the review and improvements.

>> Attached v4 is a rebase after 409231919443984635b7ae9b7e2e261ab984eb1e
>
> Attached v5. I thought that separating the part that executes the
> command was an obvious readability improvement.

Hmm. It is somehow, but the aim of the refactoring is to make *ALL* state
transitions to happen in doCustom's switch (st->state) and nowhere else,
which is defeated by creating the separate function.

Although it improves readability at one level, it does not help figuring
out what happens to states, which is my primary concern: The idea is that
reading doCustom is enough to build and check the automaton, which I had
to do repeatedly while reviewing Marina's patches.

Also the added doCustom comment, which announces this property becomes
false under the refactoring function:

All state changes are performed within this function called by threadRun.

So I would suggest not to create this function.

> Do we really use the word "move" to talk about state changes? It sounds
> very odd to me. I would change that to "transition" -- would anybody
> object to that? (Not changed in v5.)

Yep. I removed the goto:-)

> On INSTR_TIME_SET_CURRENT_LAZY(), you cannot just put an "if" inside a
> macro -- consider this:
> if (foo)
> INSTR_TIME_SET_CURRENT_LAZY(bar);
> else
> something_else();
> Which "if" is the else now attached to? Now maybe the C standard has an
> answer for that (I don't know what it is), but it's hard to read and
> likely the compiler will complain anyway. I wrapped it in "do { }
> while(0)" as is customary.

Indeed, good catch.

In the attached patched, I have I think included all your changes *but*
the separate function, for the reason discussed above, and removed the
"goto".

--
Fabien.

Attachment Content-Type Size
pgbench-state-change-6.patch text/x-diff 18.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2018-11-20 13:42:41 Re: Psql patch to show access methods info
Previous Message REIX, Tony 2018-11-20 13:36:44 RE: Shared Memory: How to use SYSV rather than MMAP ?