[ 
https://issues.apache.org/jira/browse/IO-726?focusedWorklogId=609879&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-609879
 ]

ASF GitHub Bot logged work on IO-726:
-------------------------------------

                Author: ASF GitHub Bot
            Created on: 10/Jun/21 18:46
            Start Date: 10/Jun/21 18:46
    Worklog Time Spent: 10m 
      Work Description: shollander commented on a change in pull request #215:
URL: https://github.com/apache/commons-io/pull/215#discussion_r649437283



##########
File path: 
src/main/java/org/apache/commons/io/input/MemoryMappedFileInputStream.java
##########
@@ -0,0 +1,169 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.io.input;
+
+import static org.apache.commons.io.IOUtils.EOF;
+
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.nio.channels.FileChannel;
+import java.nio.channels.FileChannel.MapMode;
+import java.nio.file.Path;
+import java.nio.file.StandardOpenOption;
+
+import org.apache.commons.io.ByteBufferCleaner;
+
+/**
+ * An {@link InputStream} that utilizes memory mapped files to improve
+ * performance. A sliding window of the file is mapped to memory to avoid
+ * mapping the entire file to memory at one time. The size of the sliding 
buffer
+ * is user configurable.
+ * 
+ * For most operating systems, mapping a file into memory is more expensive 
than
+ * reading or writing a few tens of kilobytes of data. From the standpoint of
+ * performance it is generally only worth mapping relatively large files into
+ * memory. Use of this class can provide approximately a 25% increase in
+ * throughput when reading large files. <br>

Review comment:
       The number given is based on one use case where I used this code.
   I will remove the performance claim since I don't have time to spend 
developing benchmarks.




-- 
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:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 609879)
    Time Spent: 2h 40m  (was: 2.5h)

> Add MemoryMappedInputStream
> ---------------------------
>
>                 Key: IO-726
>                 URL: https://issues.apache.org/jira/browse/IO-726
>             Project: Commons IO
>          Issue Type: New Feature
>          Components: Streams/Writers
>    Affects Versions: 2.8.0
>            Reporter: S Hollander
>            Priority: Major
>             Fix For: 2.10.0
>
>          Time Spent: 2h 40m
>  Remaining Estimate: 0h
>
> A very useful tool for improving performance with disk-based IO is the use of 
> memory mapped files. I propose an {{InputStream}} that provides a bridge 
> between memory mapped files and the {{InputStream}} ecosystem.
> In my limited performance tests, the use of the MemoryMappedInputStream 
> provided a 25% increase in throughput.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to