对PostgreSQL中bufmgr.c的进一步学习
开始
重要的是:必须了解到 静态变量的使用,它们是贯穿其BgBufferSync 的主线。在一次次调用中始终存在,值也在累积。
bool BgBufferSync(void) { /* info obtained from freelist.c */ int strategy_buf_id; uint32 strategy_passes; uint32 recent_alloc; /* * Information saved between calls so we can determine the strategy * point's advance rate and avoid scanning already-cleaned buffers. */ static bool saved_info_valid = false; static int prev_strategy_buf_id; static uint32 prev_strategy_passes; static int next_to_clean; static uint32 next_passes; /* Moving averages of allocation rate and clean-buffer density */ static float smoothed_alloc = 0; static float smoothed_density = 10.0; ...... }
[作者:技术者高健@博客园 mail: luckyjackgao@gmail.com ]
结束