79337825

Date: 2025-01-08 02:23:22
Score: 0.5
Natty:
Report link

If I specify the size of the file for the length argument would it then load the entire file?

Most likely, No. Might not load a single page into physical memory.

On our rhel linux platform, no data was loaded into physical memory. When we read a word for the first time in a mmap memory page, a page fault occurred and this fault was handled by the OS under-the-hood to load that page into physical memory. To load the entire file, we read a word on each of the mmap memory pages.

We did this before we began timing the algorithms. We didn't want the OS page faults and memory load steps to affect the basic algorithm timings.

what is the maximum sized file I can mmap on a 64-bit system?

We had enough memory to handle the entire file. Here's a link that addresses mmap limits.

Using mmap() to map a file does not copy the file to physical memory so there's no reason to limit it. As long as the entire file can be represented by the virtual address space, it can be mapped. The way this works is that each page is not resident in memory and so accessing it triggers a page fault. The kernel transparently uses this opportunity to access that part of the file.

Reasons:
  • Long answer (-1):
  • No code block (0.5):
  • Contains question mark (0.5):
  • Low reputation (0.5):
Posted by: PaulH