lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "wangzhijiang999" <wangzhijiang...@aliyun.com>
Subject mmap confusion in lucene
Date Mon, 14 Jul 2014 09:57:31 GMT
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
 
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message