RE: Using per-transaction memory contexts for storing decoded tuples

Hayato Kuroda (Fujitsu) <kuroda.hayato@fujitsu.com>

From: "Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>
To: 'Masahiko Sawada' <sawada.mshk@gmail.com>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2024-09-20T09:36:10Z
Lists: pgsql-hackers

Attachments

Dear Sawada-san,

> Thank you for your interest in this patch. I've just shared some
> benchmark results (with a patch) that could be different depending on
> the environment[1]. I would be appreciated if you also do similar
> tests and share the results.

Okay, I did similar tests, the attached script is the test runner. rb_mem_block_size
was changed from 8kB to 8MB. Below table show the result (millisecond unit).
Each cell is the average of 5 runs.

==========
8kB	12877.4
16kB	12829.1
32kB	11793.3
64kB	13134.4
128kB	13353.1
256kB	11664.0
512kB	12603.4
1MB	13443.8
2MB	12469.0
4MB	12651.4
8MB	12381.4
==========

The standard deviation of measurements was 100-500 ms, there were no noticeable
differences on my env as well.

Also, I've checked the statistics of the generation context, and confirmed the
number of allocated blocks is x1000 higher if the block size is changed 8kB->8MB.
[1] shows the output from MemoryContextStats(), just in case. IIUC, the difference
of actual used space comes from the header of each block. Each block has attributes
for management so that the total usage becomes larger based on the number.

[1]
8kB
Tuples: 724959232 total in 88496 blocks (10000000 chunks); 3328 free (0 chunks); 724955904 used
Grand total: 724959232 bytes in 88496 blocks; 3328 free (0 chunks); 724955904 used

8MB
Tuples: 721420288 total in 86 blocks (10000000 chunks); 1415344 free (0 chunks); 720004944 used
Grand total: 721420288 bytes in 86 blocks; 1415344 free (0 chunks); 720004944 use

Best regards,
Hayato Kuroda
FUJITSU LIMITED

Commits

  1. Reduce memory block size for decoded tuple storage to 8kB.

  2. Generational memory allocator