ocadaruma commented on code in PR #14289:
URL: https://github.com/apache/kafka/pull/14289#discussion_r1493877586


##########
clients/src/main/java/org/apache/kafka/common/record/FileRecords.java:
##########
@@ -421,6 +446,18 @@ private AbstractIterator<FileChannelRecordBatch> 
batchIterator(int start) {
         return new RecordBatchIterator<>(inputStream);
     }
 
+    /**
+     * Try populating OS page cache with file content
+     */
+    public void prepareForRead() throws IOException {
+        if (DEVNULL_PATH != null) {
+            long size = Math.min(channel.size(), end) - start;
+            try (FileChannel devnullChannel = FileChannel.open(DEVNULL_PATH, 
StandardOpenOption.WRITE)) {
+                channel.transferTo(start, size, devnullChannel);

Review Comment:
   > do we want to pre-populate the entire content represented by the 
FileRecords
   
   Given that FileRecords here represents a slice of the file adjusted to 
fetch-size, we want to pre-populate the entire content here because even the 
single `writeTo` might read only smaller part, network-thread anyways needs 
entire content.



-- 
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.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to