Re: BUG #14231: logical replication wal sender process spins when using error traps in function - Mailing list pgsql-bugs

From andres@anarazel.de (Andres Freund)
Subject Re: BUG #14231: logical replication wal sender process spins when using error traps in function
Date
Msg-id 20160706213116.75xgxiwva5gynkh3@alap3.anarazel.de
Whole thread Raw
In response to Re: BUG #14231: logical replication wal sender process spins when using error traps in function  (Alvaro Herrera <alvherre@2ndquadrant.com>)
List pgsql-bugs
On 2016-07-06 17:26:00 -0400, Alvaro Herrera wrote:
> Andrew Gierth wrote:
>
> > A quick scan of the code suggests that the worst case is when blocks are
> > being freed in FIFO order, which seems quite plausible in this case, and
> > the performance is potentially O(N^2).

Hrmpf.

> > So I think this is primarily an artifact of doing so much retail
> > palloc/pfree in a single memory context.
>
> As I recall, this is the main reason Andres stuck the slab cache in
> reorderbuffer.

That was primarily for allocation performance, but that's not far off.
Michael, what you could do is to adjust
static const Size max_cached_changes = 4096 * 2;
static const Size max_cached_tuplebufs = 4096 * 2;        /* ~8MB */
static const Size max_cached_transactions = 512;
to some ridiculous sizes, and see how that affects performance.


> Maybe it'd be worthwhile to implement a different
> MemoryContext tailored to this use case, and remove the slab cache
> stuff.

Hm. I'm not sure how much you could do with a memory context
itself. Seems to need an actual slab allocator, something not easily
done via the MemoryContext interface.

Andres

pgsql-bugs by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: BUG #14231: logical replication wal sender process spins when using error traps in function
Next
From: Andres Freund
Date:
Subject: Re: BUG #14231: logical replication wal sender process spins when using error traps in function