久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

checkpoint中用于控制刷盤頻率的函數是什么

166次閱讀
沒有評論

共計 3866 個字符,預計需要花費 10 分鐘才能閱讀完成。

這篇文章主要介紹“checkpoint 中用于控制刷盤頻率的函數是什么”,在日常操作中,相信很多人在 checkpoint 中用于控制刷盤頻率的函數是什么問題上存在疑惑,丸趣 TV 小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”checkpoint 中用于控制刷盤頻率的函數是什么”的疑惑有所幫助!接下來,請跟著丸趣 TV 小編一起來學習吧!

一、數據結構

宏定義
checkpoints request flag bits
checkpoints request flag bits, 檢查點請求標記位定義.

/*
 * OR-able request flag bits for checkpoints. The  cause  bits are used only
 * for logging purposes. Note: the flags must be defined so that it s
 * sensible to OR together request flags arising from different requestors.
 */
/* These directly affect the behavior of CreateCheckPoint and subsidiaries */
#define CHECKPOINT_IS_SHUTDOWN 0x0001 /* Checkpoint is for shutdown */
#define CHECKPOINT_END_OF_RECOVERY 0x0002 /* Like shutdown checkpoint, but
 * issued at end of WAL recovery */
#define CHECKPOINT_IMMEDIATE 0x0004 /* Do it without delays */
#define CHECKPOINT_FORCE 0x0008 /* Force even if no activity */
#define CHECKPOINT_FLUSH_ALL 0x0010 /* Flush all pages, including those
 * belonging to unlogged tables */
/* These are important to RequestCheckpoint */
#define CHECKPOINT_WAIT 0x0020 /* Wait for completion */
#define CHECKPOINT_REQUESTED 0x0040 /* Checkpoint request has been made */
/* These indicate the cause of a checkpoint request */
#define CHECKPOINT_CAUSE_XLOG 0x0080 /* XLOG consumption */
#define CHECKPOINT_CAUSE_TIME 0x0100 /* Elapsed time */

WRITES_PER_ABSORB

/* interval for calling AbsorbSyncRequests in CheckpointWriteDelay */
// 調用 AbsorbSyncRequests 的間隔, 默認值為 1000
#define WRITES_PER_ABSORB 1000

二、源碼解讀

CheckpointWriteDelay
CheckpointWriteDelay, 控制 checkpoint 的頻率, 邏輯不復雜, 判斷 checkpoint flags 非 CHECKPOINT_IMMEDIATE/ 非 shutdown_requested/ 非 CHECKPOINT_IMMEDIATE 并且 checkpoint 處于調度中, 如滿足上述條件, 則調用 AbsorbSyncRequests 處理 sync, 休眠 100ms; 不如滿足上述條件, 則 absorb_counter 計數器減一, 如計數器≤0, 則調用 AbsorbSyncRequests 處理 sync.

/*
 * CheckpointWriteDelay -- control rate of checkpoint
 *  控制 checkpoint 的頻率
 *
 * This function is called after each page write performed by BufferSync().
 * It is responsible for throttling BufferSync() s write rate to hit
 * checkpoint_completion_target.
 *
 * The checkpoint request flags should be passed in; currently the only one
 * examined is CHECKPOINT_IMMEDIATE, which disables delays between writes.
 *
 *  progress  is an estimate of how much of the work has been done, as a
 * fraction between 0.0 meaning none, and 1.0 meaning all done.
 */
CheckpointWriteDelay(int flags, double progress)
 static int absorb_counter = WRITES_PER_ABSORB;
 /* Do nothing if checkpoint is being executed by non-checkpointer process */
 if (!AmCheckpointerProcess())
 return;
 /*
 * Perform the usual duties and take a nap, unless we re behind schedule,
 * in which case we just try to catch up as quickly as possible.
 */
 if (!(flags   CHECKPOINT_IMMEDIATE)  // 非 CHECKPOINT_IMMEDIATE
 !shutdown_requested  // 非關閉請求
 !ImmediateCheckpointRequested()  // 非 CHECKPOINT_IMMEDIATE
 IsCheckpointOnSchedule(progress))// 處于 checkpoint 調度中
 { if (got_SIGHUP)
 {
 got_SIGHUP = false;
 ProcessConfigFile(PGC_SIGHUP);
 /* update shmem copies of config variables */
 UpdateSharedMemoryConfig();
 }
 //Absorb 吸收 (處理) 同步請求
 AbsorbSyncRequests();
 // 重置為 WRITES_PER_ABSORB(1000)
 absorb_counter = WRITES_PER_ABSORB;
 // 檢查歸檔是否超時
 CheckArchiveTimeout();
 /*
 * Report interim activity statistics to the stats collector.
 */
 // 統計信息
 pgstat_send_bgwriter();
 /*
 * This sleep used to be connected to bgwriter_delay, typically 200ms.
 * That resulted in more frequent wakeups if not much work to do.
 * Checkpointer and bgwriter are no longer related so take the Big
 * Sleep.
 */
 // 休眠 100ms
 pg_usleep(100000L);
 }
 else if (--absorb_counter  = 0)//Absorb 計數器減一
 {
 // 如計數器小于等于 0
 /*
 * Absorb pending fsync requests after each WRITES_PER_ABSORB write
 * operations even when we don t sleep, to prevent overflow of the
 * fsync request queue.
 */
 //Absorb 同步請求
 AbsorbSyncRequests();
 // 重置計數器
 absorb_counter = WRITES_PER_ABSORB;
 }
}

到此,關于“checkpoint 中用于控制刷盤頻率的函數是什么”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續學習更多相關知識,請繼續關注丸趣 TV 網站,丸趣 TV 小編會繼續努力為大家帶來更多實用的文章!

正文完
 
丸趣
版權聲明:本站原創文章,由 丸趣 2023-07-24發表,共計3866字。
轉載說明:除特殊說明外本站除技術相關以外文章皆由網絡搜集發布,轉載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 宁强县| 沙雅县| 昌乐县| 洱源县| 浮山县| 镶黄旗| 聂荣县| 福贡县| 安溪县| 余庆县| 晴隆县| 舞钢市| 石家庄市| 沂源县| 太康县| 株洲市| 阿荣旗| 互助| 科尔| 胶州市| 滕州市| 延津县| 左云县| 望谟县| 华坪县| 永寿县| 贵德县| 霍林郭勒市| 搜索| 贵南县| 吴桥县| 延安市| 额尔古纳市| 营口市| 乳山市| 鄢陵县| 山阳县| 基隆市| 巴中市| 旬阳县| 榆林市|