zoukankan      html  css  js  c++  java
  • 对PostgreSQL中bufmgr.c 的BgBufferSync的静态变量学习 prev_strategy_buf_id

    开始

    bool                
    BgBufferSync(void)                
    {                
        ……            
        /*            
         * 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;    
                    
        ……         
                    
        if (saved_info_valid)            
        {            
            ……        
            strategy_delta = strategy_buf_id - prev_strategy_buf_id;        
            strategy_delta += (long) passes_delta *NBuffers;        
            ……     
        }            
        else            
        {            
            ……        
        }            
        
    fprintf(stderr,"before saving, prev_strategy_buf_id is %d \n", prev_strategy_buf_id);
    /* Update saved info for next time */ prev_strategy_buf_id = strategy_buf_id; prev_strategy_passes = strategy_passes; saved_info_valid = true; …… fprintf(stderr,"prev_strategy_buf_id is %d \n", prev_strategy_buf_id); /* Return true if OK to hibernate */ return (bufs_to_lap == 0 && recent_alloc == 0); }

    执行的结果显示,即使我用psql 变更了某行的值,直到最后,prev_strategy_buf_id 的值也没有发生根本性的变化。

    [postgres@localhost bin]$ ./postgres -D /usr/local/pgsql/data        
    LOG:  database system was shut down at 2012-11-02 15:30:38 CST        
    saved_info_valid false.        
    before saving,prev_strategy_buf_id is: 0        
    prev_strategy_buf_id is 0         
    LOG:  autovacuum launcher started        
    LOG:  database system is ready to accept connections        
    before saving,prev_strategy_buf_id is: 0        
    prev_strategy_buf_id is 0         
    before saving,prev_strategy_buf_id is: 0        
    prev_strategy_buf_id is 0         
    before saving,prev_strategy_buf_id is: 0        
    prev_strategy_buf_id is 0         
    before saving,prev_strategy_buf_id is: 0        
    prev_strategy_buf_id is 0         
    before saving,prev_strategy_buf_id is: 0        
    prev_strategy_buf_id is 0         
            
    ……        
            
            
    before saving,prev_strategy_buf_id is: 0        
    prev_strategy_buf_id is 0         
    LOG:  received fast shutdown request        
    LOG:  aborting any active transactions        
    LOG:  autovacuum launcher shutting down        
    LOG:  shutting down        
    LOG:  database system is shut down        
    [postgres@localhost bin]$         

    [作者:技术者高健@博客园  mail: luckyjackgao@gmail.com ]

    结束

  • 相关阅读:
    Git 历史/术语/命令/基本操作
    SQL 术语/语法/基本操作-必知必会
    bootstrap cdn地址
    IDEA 快捷键 大幅提高工作效率
    Django3 模版配置/过滤器/markdown=9
    Django3 路由文件位置/文件格式/路由传值=8
    Django3 创建项目/app全流程=7
    VS Code Django解决不必要报错
    Django3 如何使用静态文件/如何自定义后台管理页面=6
    Django3 如何编写单元测试和全面测试=5
  • 原文地址:https://www.cnblogs.com/gaojian/p/2751375.html
Copyright © 2011-2022 走看看