There is an outstanding 
issue https://github.com/cloudius-systems/osv/issues/979 that describes how 
OSv creates extra copies of file data when mmap() is called for RAMFS or 
ROFS node. Possible improvement to eliminate this extra copy very likely 
requires different solution for ROFS and RAMFS.

Let us start with RAMFS as it is simpler I think. When vfs_file::*mmap*() 
is called it invokes mmu::*default_file_mmap*() that returns *file_vma* 
with *map_file_page_read* page provider which fills newly created page by 
calling read() on a file object. Given the file data originates in RAM, 
logically instead we should somehow return reference to that original area 
in memory. It is easier said than done because what should actually 
file_vma do in order to reference existing data in memory? I am guessing 
that file_vma somehow internally maps individual VM pages for given file 
mapping into physical memory pages where file data actually resides. Is it 
even possible to solve it by creating some kind of extension of file_vma or 
implementing special page provider instead of *map_file_page_read?* 

Now the ROFS situation is quite different as the data has to be loaded from 
disk when page fault is handled. Right now like with RAMF file_vma uses 
same page provider that uses file->read() to fill page with data. To 
minimize reading from disk ROFS actually uses "read-around-strategy" which 
means it will actually load 64K data from file and put it in memory which 
will stay forever. That way subsequent reads accessing data in same 64K 
area will get it quickly from RAM. One way to eliminate extra copies of 
data would to be to change this very dumb live-forever memory cache to 
something like LRU cache that could limit RAM used and eventually evict old 
data after some time. Another way is to also implement custom mmap page 
provider that could also somehow reference pages from ROFS cache.

Any thought?

Waldek 
   

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to