Does the Linux filesystem cache files efficiently?

前端 未结 5 2064
悲&欢浪女
悲&欢浪女 2020-12-25 13:08

I\'m creating a web application running on a Linux server. The application is constantly accessing a 250K file - it loads it in memory, reads it and sends back some info to

5条回答
  •  别那么骄傲
    2020-12-25 13:19

    Yes, if you do not modify the file each time you open it.

    Linux will hold the file's information in copy-on-write pages in memory, and "loading" the file into memory should be very fast (page table swap at worst).

    Edit: Though, as cdhowie points out, there is no 'linux filesystem'. However, I believe the relevant code is in linux's memory management, and is therefore independent of the filesystem in question. If you're curious, you can read in the linux source about handling vm_area_struct objects in linux/mm/mmap.c, mainly.

提交回复
热议问题