Improvements and refactoring in shmem.c - Mailing list pgsql-hackers

From Ashutosh Bapat
Subject Improvements and refactoring in shmem.c
Date
Msg-id CAExHW5uNRB9oT4pdo54qAo025MXFX4MfYrD9K15OCqe-ExnNvg@mail.gmail.com
Whole thread Raw
Responses Re: Improvements and refactoring in shmem.c
List pgsql-hackers
Hi All,

PFA two patches for $subject.

0001: Adds assertions to InitShmemAccess() and InitShmemAllocation
which indicate the conditions, EXEC_BACKEND and IsUnderPostmaster,
these functions are expected to be called. I found these annotations
to be useful when modifying these functions to handle multiple Shmem
segments required by buffer pool resizing project [1].

0002: We use two different methods to pass ShmemIndex and ShmemLock
respectively to new backends even though both the structures are
allocated before creating named structures in the shared memory. This
patch consistently uses the same method - passing via PGShmemHeader.
Further the patch gets rid of InitShmemAllocation and moves that code
inside InitShmemAccess() itself. Maybe that's overkill but at least we
would be able to call InitShmemAllocation() from InitShmemAccess() and
declare first as static within shmem.c. That way we avoid a minor risk
of InitShmemAllocation() being called twice.

We may achieve consistency by passing ShmemIndex through
BackendParameter, but I haven't tried that.

[1] https://www.postgresql.org/message-id/cnthxg2eekacrejyeonuhiaezc7vd7o2uowlsbenxqfkjwgvwj%40qgzu6eoqrglb

-- 
Best Wishes,
Ashutosh Bapat

Attachment

pgsql-hackers by date:

Previous
From: Dean Rasheed
Date:
Subject: Re: ABI Compliance Checker GSoC Project
Next
From: Amit Langote
Date:
Subject: Re: Batching in executor