Avoid dynahash's freelist in BufferAlloc. - Mailing list pgsql-hackers

From Yura Sokolov
Subject Avoid dynahash's freelist in BufferAlloc.
Date
Msg-id 4f7766222a461703dc4f2ccf333189f1afecbe7a.camel@postgrespro.ru
Whole thread Raw
List pgsql-hackers
Good day.

I found BufferAlloc unnecessary goes through dynahash's freelist when it
reuses valid buffer.

If it is avoided and dynahash's entry directly moved, 1-2% is gained in
select only pgbench (with scale factor 100 in 50 connections/50 threads
on 4 core 8ht notebook cpu 185krps=>190krps).

I've changed speculative call to BufferInsert to BufferLookup to avoid
insertion too early. (It also saves call to BufferDelete if conflicting
entry is already in). Then if buffer is valid and no conflicting entry
in a dynahash I'm moving old dynahash entry directly and without check
(since we already did the check).

If old buffer were invalid, new entry is unavoidably fetched from
freelist and inserted (also without check). But in steady state (if
there is no dropped/truncated tables/indices/databases) it is rare case.

Regards,
Sokolov Yura @ Postgres Professional
y.sokolov@postgrespro.ru
funny.falcon@gmail.com

Attachment

pgsql-hackers by date:

Previous
From: Yugo NAGATA
Date:
Subject: Re: Implementing Incremental View Maintenance
Next
From: Amit Kapila
Date:
Subject: Re: POC: Cleaning up orphaned files using undo logs