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

Commitf5930f9

Browse files
committed
Improve accounting for memory used by shared hash tables
pg_shmem_allocations tracks the memory allocated by ShmemInitStruct(),but for shared hash tables that covered only the header and hashdirectory. The remaining parts (segments and buckets) were allocatedlater using ShmemAlloc(), which does not update the shmem accounting.Thus, these allocations were not shown in pg_shmem_allocations.This commit improves the situation by allocating all the hash tableparts at once, using a single ShmemInitStruct() call. This way theShmemIndex entries (and thus pg_shmem_allocations) better reflect theproper size of the hash table.This affects allocations for private (non-shared) hash tables too, asthe hash_create() code is shared. For non-shared tables this howevermakes no practical difference.This changes the alignment a bit. ShmemAlloc() aligns the chunks usingCACHELINEALIGN(), which means some parts (header, directory, segments)were aligned this way. Allocating all parts as a single chunk removesthis (implicit) alignment. We've considered adding explicit alignment,but we've decided not to - it seems to be merely a coincidence due tousing the ShmemAlloc() API, not due to necessity.Author: Rahila Syed <rahilasyed90@gmail.com>Reviewed-by: Andres Freund <andres@anarazel.de>Reviewed-by: Nazir Bilal Yavuz <byavuz81@gmail.com>Reviewed-by: Tomas Vondra <tomas@vondra.me>Discussion:https://postgr.es/m/CAH2L28vHzRankszhqz7deXURxKncxfirnuW68zD7+hVAqaS5GQ@mail.gmail.com
1 parentbd17896 commitf5930f9

File tree

3 files changed

+222
-66
lines changed

3 files changed

+222
-66
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
#include"storage/shmem.h"
7474
#include"storage/spin.h"
7575
#include"utils/builtins.h"
76+
#include"utils/dynahash.h"
7677

7778
staticvoid*ShmemAllocRaw(Sizesize,Size*allocated_size);
7879

@@ -346,7 +347,8 @@ ShmemInitHash(const char *name,/* table string name for shmem index */
346347

347348
/* look it up in the shmem index */
348349
location=ShmemInitStruct(name,
349-
hash_get_shared_size(infoP,hash_flags),
350+
hash_get_size(infoP,hash_flags,
351+
init_size, true),
350352
&found);
351353

352354
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp