|From:||Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>|
|To:||Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>|
|Cc:||PostgreSQL Developers <pgsql-hackers(at)postgresql(dot)org>|
|Subject:||Re: PATCH: pgbench - merging transaction logs|
|Views:||Raw Message | Whole Thread | Download mbox | Resend email|
> It might be done in the other direction, though - the "writer" thread
> might collect current results at the end of the interval.
Yep, you can indeed accumulate per thread and sum on the end of the
interval, but a lock is still needed if you want exact figures.
ISTM that it is what is done for --progress, without even bothering to
lock anything (even if transactions are fast and some inconsistency arise,
this is just for showing how things are faring on stderr, so no big deal).
>> "fprintf" does a lot of processing, so it is the main issue.
> The question is whether the processing happens while holding the lock,
> though. I don't think that's the case.
Alas I'm pretty nearly sure it is necessarily the case, there is no
intermediate buffer in fprintf, the buffering is done trough the file
handler so a lock must be acquire throughout format processing.
"The POSIX standard requires that by default the stream operations are
atomic. I.e., issuing two stream operations for the same stream in two
threads at the same time will cause the operations to be executed as if
they were issued sequentially. The buffer operations performed while
reading or writing are protected from other uses of the same stream. To do
this each stream has an internal lock object which has to be (implicitly)
acquired before any work can be done. "
|Next Message||Joe Wildish||2015-05-02 21:42:24||Re: Implementing SQL ASSERTION|
|Previous Message||Noah Misch||2015-05-02 16:35:22||Re: parallel mode and parallel contexts|