Re: Keep a file in memory an any cost

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 05/11/2011 07:19 PM, Alain Spineux wrote:
> Hello I have a file, that is an index, it is open all the time by the
> application,
> but sometime the access are slow because the file was moved out of the cache.
> 
> How can I keep it in memory all the time ?
> I can read it at regular interval, but this is a little over kill ?
> 
> Any idea
> 
> thanks.
> 
> 

If you are programming something look into man mlock/man mlockall. The LVM2
codebase makes (slightly fancy) use of this to avoid swapping during device
activation in the memlock module if you're looking for an example:

http://sourceware.org/cgi-bin/cvsweb.cgi/~checkout~/LVM2/lib/mm/memlock.c?rev=1.41&content-type=text/plain&cvsroot=lvm2

Another approach which may make sense if the index is huge would be to use
hugetlb pages to back the file. These are locked into memory and are not swapped
(if allocated explicitly) but would need a bit more code to manage.

If you need to resort to hacks then you could probably do something with a
ramdisk and a small/simple filesystem. Ramdisk memory on Linux cannot be swapped
or evicted iirc (or they couldn't last time I used them - they are a touch
"quaint" these days).

See Documentation/blockdev/ramdisk.txt in the kernel docs for more.

Regards,
Bryn.

-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines

[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux