开始,在代码中加入调试信息。无关部分设省略。

bool
BgBufferSync(void)
{                                ……
    int            bufs_to_lap;                ……                            if (saved_info_valid)                            {        //added by gaojian        fprintf(stderr,"saved_info_valid true\n");                            int32        passes_delta = strategy_passes - prev_strategy_passes;                                        strategy_delta = strategy_buf_id - prev_strategy_buf_id;                        strategy_delta += (long) passes_delta *NBuffers;           ......
        if ((int32) (next_passes - strategy_passes) > 0)                        {                                    fprintf(stderr,"next_pass > strategy_passes.\n");/* we're one pass ahead of the strategy point */                    bufs_to_lap = strategy_buf_id - next_to_clean;                    ……                    }                        else if (next_passes == strategy_passes &&                        next_to_clean >= strategy_buf_id)                {            fprintf(stderr,"next_passes == strategy_passes.\n");                         /* on same pass, but ahead or at least not behind */                    bufs_to_lap = NBuffers - (next_to_clean - strategy_buf_id);                    ……                    }                        else                        {                        fprintf(stderr,"we are behind.\n"); /*                    * We're behind, so skip forward to the strategy point and start                    * cleaning from there.                    */                    next_to_clean = strategy_buf_id;                    next_passes = strategy_passes;                    bufs_to_lap = NBuffers;                    ……                    }                 }                            else                            {          fprintf(stderr,"saved_info_valid false\n");                          ……                        bufs_to_lap = NBuffers;                        }                            ……
    bufs_ahead = NBuffers - bufs_to_lap;                            ……
    num_to_scan = bufs_to_lap;     ......
    /* Execute the LRU scan */                            while (num_to_scan > 0 && reusable_buffers < upcoming_alloc_est)                            {                            //added by gaojian                        fprintf(stderr,"num_to_scan is: %d \n",num_to_scan);                        int    buffer_state = SyncOneBuffer(next_to_clean, true);                    if (++next_to_clean >= NBuffers)                        {                        next_to_clean = 0;           elog(INFO,"------------------next_passes++.\n");                    next_passes++;                    }                        num_to_scan--;                        ……                        }
    ……                            new_strategy_delta = bufs_to_lap - num_to_scan;                            new_recent_alloc = reusable_buffers - reusable_buffers_est;                            if (new_strategy_delta > 0 && new_recent_alloc > 0)                            {                            scans_per_alloc = (float) new_strategy_delta / (float) new_recent_alloc;                        smoothed_density += (scans_per_alloc - smoothed_density) /                        smoothing_samples;                    ……                        }    ......
}                                

运行的结果会如何呢?

[postgres@localhost bin]$ ./postgres -D /usr/local/pgsql/data
LOG:  database system was shut down at 2012-11-02 13:51:46 CST
saved_info_valid false.
LOG:  autovacuum launcher started
LOG:  database system is ready to accept connections
saved_info_valid true.
next_passes == strategy_passes.
saved_info_valid true.
next_passes == strategy_passes.
saved_info_valid true.
next_passes == strategy_passes.
saved_info_valid true.
next_passes == strategy_passes.
saved_info_valid true.
......

也就是说,一开始  saved_info_valid 是 false, 后来经过一次运行后,其值才发生转变,变成 true。

而之后, next_passes == startegy_passes  (其实,一开始都是零)

结束

转载于:https://www.cnblogs.com/gaojian/archive/2012/11/02/2751104.html

对PostgreSQL中bufmgr.c 中 bufs_to_lap的初步理解相关推荐

  1. PostgreSQL 在WAL文件中查找drop table、update、delete操作

    配套视频 要还原数据前必须查找对应的wal文件中的lsn号,步骤如下: 根据大致的操作时间先确认大至wal文件的范围. 解析此范围内的wal文件然后输出至文本. 在文本中根据特征中查找.如果未找到请扩 ...

  2. C#中Winform程序中如何实现多维表头【不通过第三方报表程序】

    问题:C#中Winform程序中如何实现多维表头. 在网上搜了很多方法,大多数方法对于我这种新手,看的都不是很懂.最后在新浪博客看到了一篇比较易懂的文章:[DataGridView二维表头与合并单元格 ...

  3. 关于python缩进的描述中_关于Python程序中与“缩进”有关的说法中,以下选项中正确的是()...

    关于Python程序中与"缩进"有关的说法中,以下选项中正确的是() 答:缩进在程序中长度统一且强制使用 同文学或同音乐主题的民歌,<_______>是其中之一.此曲经 ...

  4. python中json dumps_python中json.loads,dumps,jsonify使用

    search_info = {'id':132,'user_role':3} print type(search_info) #输出 #转为string用dumps print type(json.d ...

  5. VS2010中“工具选项中的VC++目录编辑功能已被否决”解决方法

    http://blog.csdn.net/chaijunkun/article/details/6658923 这是VS2010的改变,不能够在"工具-选项"中看到"VC ...

  6. django-celery中配置celery中的日志

    django-celery中配置celery中的日志 django配置文件中的logging只是针对django中的views.API起作用,对celery不起作用,也就是说celery不能使用dja ...

  7. 为什么,AX中存储的数据与我们日常理解相违背。

    因为它是小端存储. 又因为AX=AH+AL: 即最低地址存放的最低字节:(低地址放在AX中的AL中.这与我们日常理解的相背.) 一个用十六进制表示的32位数据:0x12345678,存放在存储字长是3 ...

  8. word录入表单数据 java 导入系统,java导入excel | 怎么把excel中的数据批量导入到word中的表格中...

    用javascript怎么实现把excel中的数据批量导入到数据库表中 这个js不能直接实现吧 我们程序用到 先读取excel内容转换成数组 然后放到页面上 再提交表单 储存 MySql如何批量添加数 ...

  9. php数组重复值销毁,如何从PHP中删除数组中的重复值

    如何从PHP中删除数组中的重复值 如何从PHP中删除数组中的重复值? 21个解决方案 204 votes 使用array_unique(). 例: $array = array(1, 2, 2, 3) ...

  10. oracle urlencode 中文,Python2和Python3中urllib库中urlencode的使用注意事项

    前言 在Python中,我们通常使用urllib中的urlencode方法将字典编码,用于提交数据给url等操作,但是在Python2和Python3中urllib模块中所提供的urlencode的包 ...

最新文章

  1. Elk5安装X-Pack
  2. 命名实体识别_用膨胀卷积进行命名实体识别 NER
  3. 【多线程】C++11进行多线程开发 (std::thread)
  4. GPU Gems 3
  5. 用python语言调试程序你用的平台是_Python 程序如何高效地调试?
  6. rstudio python_如虎添翼:用Python与C++扩展R语言的应用场景
  7. ABAP UDO generation report
  8. OSChina 周四乱弹 —— 熊孩子毁灭世界
  9. 数据结构与算法-时间复杂度
  10. 面试中被问到HashMap的结构,1.7和1.8有哪些区别?这篇做深入分析!
  11. 单个对象和多个对象在内存中的结构图
  12. 读书笔记-《 我的成功可以复制》四
  13. hbase数据库详解
  14. 西门子mag6000接线_西门子MAG5000/6000电磁流量计应用及安装
  15. 南北互联网创业者的差异
  16. 大S《美容大王》内容80%都是没用的东西
  17. 可信安全网络 —— 安全左移之DDoS对抗
  18. 前端·在线随机生成图片 免费 API
  19. TokenClub (TCT)今日在赛贝CYBEX交易所上线交易
  20. smbus协议的command_SMBus协议总结

热门文章

  1. mac文件修改权限设置
  2. java免安装版配置_Java环境变量一键配置
  3. Spring源码之创建AOP代理
  4. 【渝粤教育】国家开放大学2018年秋季 0300-22T图形创意 参考试题
  5. firefox 插件配置
  6. matlab中K=[K,temp]含义
  7. cp: 略过目录XXXXXX
  8. 【转】Using hash_map on GCC
  9. 使用cJSON库解析和构建JSON字符串
  10. 雷林鹏分享:PHP XML Parser 函数