Re: Pluggable cumulative statistics

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Dmitry Dolgov <9erthalion6(at)gmail(dot)com>
Cc: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>, Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Pluggable cumulative statistics
Date: 2024-07-18 05:56:20
Message-ID: ZpiuhF0g6Xop2TKA@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jul 16, 2024 at 10:27:25AM +0900, Michael Paquier wrote:
> Perhaps we should have a few more inline functions like
> pgstat_get_entry_len() to retrieve the parts of the custom data in the
> snapshot and shmem control structures for fixed-numbered stats. That
> would limit what extensions need to know about
> pgStatLocal.shmem->custom_data[] and
> pgStatLocal.snapshot.custom_data[], which is easy to use incorrectly.
> They don't need to know about pgStatLocal at all, either.
>
> Thinking over the weekend on this patch, splitting injection_stats.c
> into two separate files to act as two templates for the variable and
> fixed-numbered cases would be more friendly to developers, as well.

I've been toying a bit with these two ideas, and the result is
actually neater:
- The example for fixed-numbered stats is now in its own new file,
called injection_stats_fixed.c.
- Stats in the dshash are at the same location, injection_stats.c.
- pgstat_internal.h gains two inline routines called
pgstat_get_custom_shmem_data and pgstat_get_custom_snapshot_data that
hide completely the snapshot structure for extensions when it comes to
custom fixed-numbered stats, see the new injection_stats_fixed.c that
uses them.
--
Michael

Attachment Content-Type Size
v7-0001-Switch-PgStat_Kind-from-enum-to-uint32.patch text/x-diff 3.1 KB
v7-0002-Introduce-pluggable-APIs-for-Cumulative-Statistic.patch text/x-diff 20.2 KB
v7-0003-Add-helper-routines-to-retrieve-custom-data-for-f.patch text/x-diff 2.1 KB
v7-0004-doc-Add-section-for-Custom-Cumulative-Statistics-.patch text/x-diff 3.3 KB
v7-0005-injection_points-Add-statistics-for-custom-points.patch text/x-diff 14.2 KB
v7-0006-injection_points-Add-example-for-fixed-numbered-s.patch text/x-diff 11.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message jian he 2024-07-18 06:04:00 Re: pgsql: Add more SQL/JSON constructor functions
Previous Message shveta malik 2024-07-18 05:50:22 Re: Conflict detection and logging in logical replication