Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit09adc9a

Browse files
committed
Align all shared memory allocations to cache line boundaries.
Experimentation shows this only costs about 6kB, which seems wellworth it given the major performance effects that can be causedby insufficient alignment, especially on larger systems.Discussion: 14166.1458924422@sss.pgh.pa.us
1 parent1d2fe56 commit09adc9a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

‎src/backend/storage/ipc/shmem.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,17 @@ ShmemAlloc(Size size)
171171
void*newSpace;
172172

173173
/*
174-
* ensure all space is adequately aligned.
174+
* Ensure all space is adequately aligned. We used to only MAXALIGN this
175+
* space but experience has proved that on modern systems that is not good
176+
* enough. Many parts of the system are very sensitive to critical data
177+
* structures getting split across cache line boundaries. To avoid that,
178+
* attempt to align the beginning of the allocation to a cache line
179+
* boundary. The calling code will still need to be careful about how it
180+
* uses the allocated space - e.g. by padding each element in an array of
181+
* structures out to a power-of-two size - but without this, even that
182+
* won't be sufficient.
175183
*/
176-
size=MAXALIGN(size);
184+
size=CACHELINEALIGN(size);
177185

178186
Assert(ShmemSegHdr!=NULL);
179187

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp