public inbox for [email protected]  
help / color / mirror / Atom feed
From: Álvaro Herrera <[email protected]>
To: Dmitry Koterov <[email protected]>
Cc: [email protected] <[email protected]>
Subject: Re: hash_search_with_hash_value is high in "perf top" on a replica
Date: Fri, 31 Jan 2025 15:25:18 +0100
Message-ID: <[email protected]> (raw)
In-Reply-To: <CA+CZih5R_ZMjcuMHM3Ub10vTNDLEBjW8VsO3h-y2WKb=oK4fWw@mail.gmail.com>

On 2025-Jan-31, Dmitry Koterov wrote:

> PG "startup recovering" eats up a lot of CPU (like 65 %user and 30 %sys),
> which is a little surprising (what is it doing with all those CPU cycles?
> it looked like WAL replay should be more IO bound than CPU bound?).
> 
> Running "perf top -p <pid>", it shows this:
> 
> Samples: 1M of event 'cycles:P', 4000 Hz, Event count (approx.):
> 18178814660 lost: 0/0 drop: 0/0
> Overhead  Shared Object     Symbol
>   16.63%  postgres          [.] hash_search_with_hash_value

Yeah, I noticed that this function was showing high in some profiles a
couple of days ago as well.  Looking now at hashfn.c (hash_bytes_uint32
there is the function involved in the buffer mapping hash table), the
comments state that we're updated to Bob Jenkins code from 2006, but
there's a version in his website that (if I read correctly) is twice as
fast as what we're using now:
http://burtleburtle.net/bob/hash/spooky.html

Apparently this code in our repo is mostly unchanged since commit
1f559b7d3aa4, in 2007.

He mentions that on Intel chips, Google's CityHash is faster; but they
in turn claim that the difference is small on Intel chips and that
Jenkins' hash is better on AMD chips.
https://github.com/google/cityhash

Anyway if you wanted to try your luck at improving things, here's your
chance.

-- 
Álvaro Herrera               48°01'N 7°57'E  —  https://www.EnterpriseDB.com/






view thread (10+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: hash_search_with_hash_value is high in "perf top" on a replica
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox