GNOME Bugzilla – Bug 720184
Add a shared version of g_mapped_file_new(_from_fd) functions
Last modified: 2018-02-16 13:23:29 UTC
Creating writable shared mappings was not initially implemented in bug 148218 as there were no relevant use cases for that back then. However it left the door open to a future addition of g_mapped_file_new_shared(_from_file). We need this kind of mappings to improve the HTTP cache in libsoup. Having a on-disk backed mmap will allow us to do things like having read/write files divided in logical blocks were we could store small resources retrieved from the net. Those files will be also use to serve those resources quickly by the soup cache if they are fresh enough. Having multiple resources in a single mmap'ed file allows us not to have to write each small resource to a different file and save disk (due to fragmentation) and also all the syscalls burden associated to opening and writing multiple files. Performance reading those small resources is expected to improve too.
Created attachment 263907 [details] [review] Patch
Seems like you're solving two problems here, but only solving one of them half way: - adding a way to use GMappedFile with an existing fd - adding a way to get a shared mapping but you only provide the _fd path for shared mappings. Which of these APIs do you actually need?
(In reply to comment #2) > Seems like you're solving two problems here, but only solving one of them half > way: > > - adding a way to use GMappedFile with an existing fd This is already available (but only for private mappings) > - adding a way to get a shared mapping This is the API I'm actually adding, a way to get a shared mapping by specifying either a filename or by providing a fd (as the current API) > but you only provide the _fd path for shared mappings. Why do you say this?
Bug #458796 is already about adding MAP_SHARED support to GMappedFile. Since the patches here and there are both quite out of date, we’ll probably end up with some hybrid of the two (since support for creating a shared mapping from an existing FD would be good; the patches in bug #458796 don’t have that at the moment). *** This bug has been marked as a duplicate of bug 458796 ***