lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Muir <rcm...@gmail.com>
Subject Re: mmap confusion in lucene
Date Mon, 14 Jul 2014 10:08:16 GMT
Your code isn't doing what you think it is doing. You need to ensure
things aren't eliminated by the compiler.

On Mon, Jul 14, 2014 at 5:57 AM, wangzhijiang999
<wangzhijiang999@aliyun.com> wrote:
> Hi everybody,         I found a problem confused me when I tested the mmap feature in
lucene. I tested to read a file size of 800M by mmap method like below:
>
> RandomAccessFile raf = new RandomAccessFile(new File(path), "r");
> FileChannel rafc = raf.getChannel();ByteBuffer buff = rafc.map(FileChannel.MapMode.READ_ONLY,
0, rafc.size());
>  int len=buff.limit(); byte[] b = new byte[len];   for (int i = 0; i < len; i++){
        b[i] = buff.get();  }
> After the program finished, the linux cache will be consumed about 800M.
>
>
> RandomAccessFile raf = new RandomAccessFile(new File(path), "r");
> FileChannel rafc = raf.getChannel();ByteBuffer buff = rafc.map(FileChannel.MapMode.READ_ONLY,
0, rafc.size());
>  int len=buff.limit(); for (int i = 0; i < len; i++){         Byte b= buff.get();
 }
> But in this way, the linux cache will be consumed just 4M.
>
>
> RandomAccessFile raf = new RandomAccessFile(new File(path), "r");
> FileChannel rafc = raf.getChannel();ByteBuffer buff = rafc.map(FileChannel.MapMode.READ_ONLY,
0, rafc.size());
>  int len=buff.limit(); byte[] b = new byte[len];   for (int i = 0; i < len; i++){
        b[i] = buff.get();
>          b[i]=0;  }
> In this way, the linux cache will  be also consumed 4M.
>
> The whole content of the file should be read for above three tests, but for the last
two testings, the linux system only cached 4M .
> Would somebody give me the explaination about this? Thanks in advane.
>
> Zhijiang Wang
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message