@@ -72,10 +72,17 @@ static bool wf_incremental_init(xb_write_filt_ctxt_t *ctxt, char *dst_name,
7272 (cursor->page_size / 4 + 1 ) * cursor->page_size + UNIV_PAGE_SIZE_MAX ;
7373 cp->delta_buf_base = static_cast <byte *>(
7474 ut::malloc_withkey (UT_NEW_THIS_FILE_PSI_KEY , buf_size));
75- memset (cp->delta_buf_base , 0 , buf_size);
7675 cp->delta_buf =
7776 static_cast <byte *>(ut_align (cp->delta_buf_base , UNIV_PAGE_SIZE_MAX ));
7877
78+ /* OPTIMIZATION: Only zero the first page (header/index page).
79+ Previously, we zeroed the entire buffer (~67MB), which triggered massive
80+ OS page faults (asm_exc_page_fault) and consumed significant CPU (~80%).
81+ We only need the header page to be clean so that no garbage follows the
82+ 0xFFFFFFFF sentinel. The data pages are overwritten by memcpy or never
83+ written to disk.*/
84+ memset (cp->delta_buf , 0 , cursor->page_size );
85+
7986 /* write delta meta info */
8087 snprintf (meta_name, sizeof (meta_name), " %s%s" , dst_name,
8188 XB_DELTA_INFO_SUFFIX );
@@ -135,7 +142,11 @@ static bool wf_incremental_process(xb_write_filt_ctxt_t *ctxt,
135142 }
136143
137144 /* clear buffer */
138- memset (cp->delta_buf , 0 , page_size / 4 * page_size);
145+ /* OPTIMIZATION: Only clear the header page for the next batch.
146+ The rest of the buffer will be overwritten by new data pages.
147+ Since we track 'npages', we never write the dirty tail to disk,
148+ so zeroing the whole buffer is wasted memory bandwidth.*/
149+ memset (cp->delta_buf , 0 , page_size);
139150 /* "xtra"*/
140151 mach_write_to_4 (cp->delta_buf , 0x78747261UL );
141152 cp->npages = 1 ;
0 commit comments