core: Use mmap() with O_NOATIME if merely reading archive-z2 entries
Previously we'd open(path, O_NOATIME) and do a series of small read() calls to just parse the header. I think this will trigger kernel readahead into the compressed portion, but we don't care about that. This should be more efficient.
This commit is contained in:
1 parent
7fcebed4e8
commit
fc7f05940c
2 files changed
+19
-2
No files matched your search
+1
-1
Submodule src/libgsystem updated: c17376d4ac...76d4b35637.
@@ -540,10 +540,11 @@ ostree_content_file_parse (gboolean compressed,
|
|||||||
struct stat stbuf;
|
struct stat stbuf;
|
||||||
ot_lobj GInputStream *file_input = NULL;
|
ot_lobj GInputStream *file_input = NULL;
|
||||||
ot_lobj GInputStream *ret_input = NULL;
|
ot_lobj GInputStream *ret_input = NULL;
|
||||||
ot_lobj GFileInfo *content_file_info = NULL;
|
|
||||||
ot_lobj GFileInfo *ret_file_info = NULL;
|
ot_lobj GFileInfo *ret_file_info = NULL;
|
||||||
ot_lvariant GVariant *ret_xattrs = NULL;
|
ot_lvariant GVariant *ret_xattrs = NULL;
|
||||||
|
|
||||||
|
if (out_input)
|
||||||
|
{
|
||||||
file_input = (GInputStream*)gs_file_read_noatime (content_path, cancellable, error);
|
file_input = (GInputStream*)gs_file_read_noatime (content_path, cancellable, error);
|
||||||
if (!file_input)
|
if (!file_input)
|
||||||
goto out;
|
goto out;
|
||||||
@@ -555,6 +556,22 @@ ostree_content_file_parse (gboolean compressed,
|
|||||||
}
|
}
|
||||||
|
|
||||||
length = stbuf.st_size;
|
length = stbuf.st_size;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GMappedFile *mmaped;
|
||||||
|
GBytes *bytes;
|
||||||
|
|
||||||
|
mmaped = gs_file_map_noatime (content_path, cancellable, error);
|
||||||
|
if (!mmaped)
|
||||||
|
goto out;
|
||||||
|
bytes = g_mapped_file_get_bytes (mmaped);
|
||||||
|
g_mapped_file_unref (mmaped);
|
||||||
|
mmaped = NULL;
|
||||||
|
file_input = g_memory_input_stream_new_from_bytes (bytes);
|
||||||
|
length = g_bytes_get_size (bytes);
|
||||||
|
g_bytes_unref (bytes);
|
||||||
|
}
|
||||||
|
|
||||||
if (!ostree_content_stream_parse (compressed, file_input, length, trusted,
|
if (!ostree_content_stream_parse (compressed, file_input, length, trusted,
|
||||||
out_input ? &ret_input : NULL,
|
out_input ? &ret_input : NULL,
|
||||||
|
|||||||
Reference in new issue
Block a user