我是数据库和Postgres的新手,我正在分析Postgres在方法“CreateSharedMemoryAndSemaphores”中分配的内存。
类似变量“size”以默认值100000开头,然后添加一堆共享内存,如“SpinlockSemaSize”,“LockShmemSize”等。
有没有办法知道哪个方法为变量添加了多少内存?
size = 100000;
size = add_size(size, SpinlockSemaSize());
size = add_size(size, hash_estimate_size(SHMEM_INDEX_SIZE,
sizeof(ShmemIndexEnt)));
size = add_size(size, BufferShmemSize());
size = add_size(size, LockShmemSize());
size = add_size(size, PredicateLockShmemSize());
size = add_size(size, ProcGlobalShmemSize());
size = add_size(size, XLOGShmemSize());
size = add_size(size, CLOGShmemSize());
size = add_size(size, CommitTsShmemSize());
size = add_size(size, SUBTRANSShmemSize());
size = add_size(size, TwoPhaseShmemSize());
size = add_size(size, BackgroundWorkerShmemSize());
size = add_size(size, MultiXactShmemSize());
size = add_size(size, LWLockShmemSize());
size = add_size(size, ProcArrayShmemSize());
size = add_size(size, BackendStatusShmemSize());
size = add_size(size, SInvalShmemSize());
size = add_size(size, PMSignalShmemSize());
size = add_size(size, ProcSignalShmemSize());
size = add_size(size, CheckpointerShmemSize());
size = add_size(size, AutoVacuumShmemSize());
答案 0 :(得分:0)
要确定每行对总数的精确数量,您必须阅读各个函数定义。
但通常到目前为止最大的部分来自
size = add_size(size, BufferShmemSize());
计算共享PostgreSQL页面缓存的共享缓冲区的空间。
在BufferShmemSize()
中,最重要的贡献来自这一行:
/* size of data pages */
size = add_size(size, mul_size(NBuffers, BLCKSZ));
NBuffers
是一个全局变量,包含postgresql.conf
参数shared_buffers
(PostgreSQL中的GUC用语),BLCKSZ
为8192,除非在pg_config.h
中手动更改{1}},几乎没有人这样做。