Re: Using condition variables to wait for checkpoints

From: Andres Freund <andres(at)anarazel(dot)de>
To: Thomas Munro <thomas(dot)munro(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Using condition variables to wait for checkpoints
Date: 2019-03-12 23:12:04
Message-ID: 20190312231204.k5jqe7x2wetl6m6u@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2019-03-13 11:56:19 +1300, Thomas Munro wrote:
> A user complained about CREATE DATABASE taking > 200ms even with fsync
> set to off. Andres pointed out that that'd be the clunky poll/sleep
> loops in checkpointer.c.
>
> Here's a draft patch to use condition variables instead.
>
> Unpatched:
>
> postgres=# checkpoint;
> CHECKPOINT
> Time: 101.848 ms
>
> Patched:
>
> postgres=# checkpoint;
> CHECKPOINT
> Time: 1.851 ms

Neat. That's with tiny shmem though, I bet?

> + <row>
> + <entry><literal>CheckpointDone</literal></entry>
> + <entry>Waiting for a checkpoint to complete.</entry>
> + </row>

> + <row>
> + <entry><literal>CheckpointStart</literal></entry>
> + <entry>Waiting for a checkpoint to start.</entry>
> + </row>

Not sure I like these much, but I can't quite ome up with something
meaningfully better.

Looks good to me. Having useful infrastructure is sure cool.

- Andres

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Shawn Debnath 2019-03-12 23:24:54 Introduce timeout capability for ConditionVariableSleep
Previous Message Thomas Munro 2019-03-12 22:56:19 Using condition variables to wait for checkpoints