lundi 7 avril 2014

c - avantages/inconvénients de mappage d'un fichier entier vs blocs si nécessaire - Stack Overflow


What are the advantages/disadvantages of mapping a whole file once vs. mapping large blocks when needed in an algorithm?


Intuitively, I would say it makes most sense just to map the whole file and then let the OS take care of reading/writing to disk when needed instead of making a lot of system calls since the OS is not actually reading the mapped file before accessed. At least on a 64 bit system where the address space isn't an issue.


Some context:


This is for an external priority heap developed during a course on I/O algorithms. Our measurements shows that is slightly better to just map the whole underlying file instead of mapping blocks (nodes in a tree) when needed. However, our professor does not trust our measurements and says that he didn't expect that behaviour. Is there anything we are missing?


We are using mmap with PROT_READ | PROT_WRITE and MAP_SHARED.


Thanks, Lasse



What are the advantages/disadvantages of mapping a whole file once vs. mapping large blocks when needed in an algorithm?


Intuitively, I would say it makes most sense just to map the whole file and then let the OS take care of reading/writing to disk when needed instead of making a lot of system calls since the OS is not actually reading the mapped file before accessed. At least on a 64 bit system where the address space isn't an issue.


Some context:


This is for an external priority heap developed during a course on I/O algorithms. Our measurements shows that is slightly better to just map the whole underlying file instead of mapping blocks (nodes in a tree) when needed. However, our professor does not trust our measurements and says that he didn't expect that behaviour. Is there anything we are missing?


We are using mmap with PROT_READ | PROT_WRITE and MAP_SHARED.


Thanks, Lasse


0 commentaires:

Enregistrer un commentaire