对PostgreSQL中bufmgr.c的进一步学习

本文深入探讨了静态变量在BgBufferSync函数中的关键应用,包括它们如何在整个函数调用过程中保持存在,以及如何积累信息以确定策略点的进展速度并避免重复清理已清洁缓冲区。

开始

重要的是:必须了解到 静态变量的使用,它们是贯穿其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 ]

结束

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值