You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This function calls many functions which return the amount of shared
memory required for different shared memory data structures. Up until
now, the returned total of these sizes was used to create a single
shared memory segment. But starting the previous patch, we create
multiple shared memory segments each of which contain one shared memory
structure related to shared buffers and one main memory segment
containing rest of the structures. Since CalculateShmemSize() is called
for every shared memory segment, and its return value is added to the
memory required for all the shared memory segments, we end up allocating
more memory than required.
Instead, CalculateShmemSize() is called only once. Each of its callees
are expected to a. return the size required from the main segment b. add
sizes to the AnonymousMappings corresponding to the other memory
segments.
For individual modules to add memory to their respective
AnonymousMappings, we need to know the different mappings upfront. Hence
ANON_MAPPINGS replaces next_free_segment.
TODOs:
1. This change however requires that the AnonymousMappings array and
macros defining identifiers of each of the segments be
platform-independent. This patch doesn't achieve that goal for all the
platforms for example windows. We need to fix that.
2. If postgres is invoked with -C shared_memory_size, it reports 0.
That's because it report the GUC values before share memory sizes are
set in AnonymousMappings. Fix that too.
3. Eliminate this assymetry in CalculateShmemSize(). See TODO in
prologue of CalculateShmemSize().
4. This is one way to avoid requesting more memory in each segment. But
there may be other ways to design CalculateShmemSize(). Need to think
and implement it better.
Author: Ashutosh Bapat
0 commit comments