rushsky518 opened a new issue #1731: question about warmMappedFile
URL: https://github.com/apache/rocketmq/issues/1731
 
 
   `public void warmMappedFile(FlushDiskType type, int pages) {
        long beginTime = System.currentTimeMillis();
        ByteBuffer byteBuffer = this.mappedByteBuffer.slice();
        int flush = 0;
        long time = System.currentTimeMillis();
        for (int i = 0, j = 0; i < this.fileSize; i += MappedFile.OS_PAGE_SIZE, 
j++) {
                // 每一个 4k 页,写入一个字节 0
                byteBuffer.put(i, (byte) 0);
                // force flush when flush disk type is sync
                if (type == FlushDiskType.SYNC_FLUSH) {
                        if ((i / OS_PAGE_SIZE) - (flush / OS_PAGE_SIZE) >= 
pages) {
                                flush = i;
                                mappedByteBuffer.force();
                        }
                }
   
                // prevent gc
                if (j % 1000 == 0) {
                        log.info("j={}, costTime={}", j, 
System.currentTimeMillis() - time);
                        time = System.currentTimeMillis();
                        try {
                                Thread.sleep(0);
                        } catch (InterruptedException e) {
                                log.error("Interrupted", e);
                        }
                }
        }
   
        // force flush when prepare load finished
        if (type == FlushDiskType.SYNC_FLUSH) {
                log.info("mapped file warm-up done, force to disk, 
mappedFile={}, costTime={}",
                        this.getFileName(), System.currentTimeMillis() - 
beginTime);
                mappedByteBuffer.force();
        }
        log.info("mapped file warm-up done. mappedFile={}, costTime={}", 
this.getFileName(),
                System.currentTimeMillis() - beginTime);
   
        this.mlock();
   }
   `
   value of param pages is 4096
   `private int flushLeastPagesWhenWarmMapedFile = 1024 / 4 * 16`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to