Re: Use generation context to speed up tuplesorts

From: Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>
To: Ronan Dunklau <ronan(dot)dunklau(at)aiven(dot)io>, Julien Rouhaud <rjuju123(at)gmail(dot)com>, David Rowley <dgrowleyml(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Cc: Andres Freund <andres(at)anarazel(dot)de>, Tomas Vondra <tv(at)fuzzy(dot)cz>
Subject: Re: Use generation context to speed up tuplesorts
Date: 2022-02-12 20:44:32
Message-ID: 5faa695b-30f2-464b-5a97-90f5b4bff3b4@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 1/25/22 13:34, Ronan Dunklau wrote:
>
> ...
>
> I've run the same 1-to-32-columns sort benchmark, using both glibc malloc and
> jemalloc, with the standard aset memory manager or with David's generation v2
> patch. To use jemalloc, I just use a LD_PRELOAD env variable before starting
> postgres.
>
> I have not tried to measure jemalloc's memory footprint like I did for glibc's
> malloc in the previous benchmark, as I'm not trying to evaluate jemalloc as a
> glibc's malloc replacement.
>
> Please find the results attached. As I suspected, most of the gain observed
> with David's patch come from working around glibc's malloc idiosyncracies but
> the good news is that it also helps (to a lesser degree) with jemalloc.
>
> I'm not sure how that would behave with growing block sizes though: as Tomas
> patch and stress-testing benchmarks showed, we can hit some particular
> thresholds (and regressions) in glibc's self-tuning behaviour.
>

Interesting results!

So just switching to jemalloc can yield much better performance (in some
cases), even beating the generation context (on top of glibc malloc).

Of course, those are just simple (somewhat synthetic) benchmarks, and
there is no info about memory consumption. Perhaps there are cases where
this would be slower than glibc malloc, and I doubt many people to
switch to a non-default malloc implementation.

But I think in general this mostly confirms our suspicion about the
patch (somewhat accidentally) working around glibc internal behavior.

regards

--
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2022-02-12 20:56:09 Re: Use generation context to speed up tuplesorts
Previous Message Anders Kaseorg 2022-02-12 20:36:26 Re: PGroonga index-only scan problem with yesterday’s PostgreSQL updates