After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 720184 - Add a shared version of g_mapped_file_new(_from_fd) functions
Add a shared version of g_mapped_file_new(_from_fd) functions
Status: RESOLVED DUPLICATE of bug 458796
Product: glib
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks: 666143
 
 
Reported: 2013-12-10 10:42 UTC by Sergio Villar
Modified: 2018-02-16 13:23 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch (11.79 KB, patch)
2013-12-10 10:49 UTC, Sergio Villar
none Details | Review

Description Sergio Villar 2013-12-10 10:42:30 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.
Comment 1 Sergio Villar 2013-12-10 10:49:41 UTC
Created attachment 263907 [details] [review]
Patch
Comment 2 Allison Karlitskaya (desrt) 2013-12-10 12:52:41 UTC
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?
Comment 3 Sergio Villar 2013-12-10 18:18:19 UTC
(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?
Comment 4 Philip Withnall 2018-02-16 13:23:29 UTC
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 ***