| From: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com> |
|---|---|
| To: | Michael Paquier <michael(at)paquier(dot)xyz> |
| Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: Remove useless pointer advance in StatsShmemInit() |
| Date: | 2025-12-02 07:40:44 |
| Message-ID: | aS6X/ANu70ujALPu@ip-10-97-1-34.eu-west-3.compute.internal |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
On Tue, Aug 19, 2025 at 10:00:37AM +0900, Michael Paquier wrote:
> On Mon, Aug 18, 2025 at 09:31:14AM +0000, Bertrand Drouvot wrote:
> > Yeah, that's probably just a matter of taste, but I also prefer keeping the
> > pointer over just doing:
> >
> > ctl->raw_dsa_area = (char *) ctl + MAXALIGN(sizeof(PgStat_ShmemControl));
>
> Done as you have suggested.
Here are a few more that have been found with [1]. I did review all of them
carefully and they look legitimate to remove.
That said, I chose not to remove some and added comments instead for:
- the last ones in ParseCommitRecord(), ParseAbortRecord() and ParsePrepareRecord()
- some in ReorderBufferSerializeChange()
- the one in SnapBuildSerialize()
The reason is that, while they are currently useless, they would need to be
added back if we add more branches/cases. So I preferred to stay on the safe side
of thing.
Remarks:
- we could also add a comment instead of removing the one in DecodeXLogRecord(),
but we're in the "and finally, the main data" part so I don't think there are
risks to have to add it back.
- for the ones in ReorderBufferRestoreChange(): While data is a parameter,
modifying the pointer itself (not *data) only affects the local copy, so these
increments are dead code.
- for the ones in pgaio_uring_shmem_init(), I'm not sure if we should keep them
for "documentation" purpose or remove them. The current patch removes them,
but feedback is welcome.
[1]: https://github.com/bdrouvot/coccinelle_on_pg/blob/main/misc/unused_pointers_after_last_update.cocci
Regards,
--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Remove-useless-pointer-updates.patch | text/x-diff | 8.4 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Peter Eisentraut | 2025-12-02 07:44:28 | Re: Consistently use the XLogRecPtrIsInvalid() macro |
| Previous Message | Michael Paquier | 2025-12-02 07:32:09 | Re: Remove unused function parameters, part 2: replication |