79363795

Date: 2025-01-17 06:24:15
Score: 0.5
Natty:
Report link

After conducting a little research, I decided for myself that the most correct way is to

    munmap
    ftruncate
    mmap

Q: Wouldn't it be extremely costly if you need to change the size of a mapped file all the time (transfer data from HDD to RAM back and forth)?

A:

Q: Does the munmap syscall provide writing back to the disk file?

A: Yes, munmap = munmap + msync + MS_ASYNC.

Q: Does

munmap + truncate + mmap

show better performance than

msync + munmap + truncate + mmap ?

A: Only the use of msync + MS_SYNC causes the overhead of excessive writing operations to HDD. To avoid it, you can omit using msync (it will be the same as using msync + MS_ASYNC).

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Contains question mark (0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Fyodor