- Notifications
You must be signed in to change notification settings - Fork5.2k
Commitf5930f9
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.com1 parentbd17896 commitf5930f9
File tree
3 files changed
+222
-66
lines changed- src
- backend
- storage/ipc
- utils/hash
- include/utils
3 files changed
+222
-66
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
| 76 | + | |
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
| |||
346 | 347 | | |
347 | 348 | | |
348 | 349 | | |
349 | | - | |
| 350 | + | |
| 351 | + | |
350 | 352 | | |
351 | 353 | | |
352 | 354 | | |
| |||
0 commit comments
Comments
(0)