[ostree] core: Use mmap() with O_NOATIME if merely reading archive-z2 entries
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] core: Use mmap() with O_NOATIME if merely reading archive-z2 entries
- Date: Sun, 2 Dec 2012 20:22:13 +0000 (UTC)
commit fc7f05940c6c7ff2e778c562ab51303879b82e4b
Author: Colin Walters <walters verbum org>
Date: Sun Dec 2 15:20:17 2012 -0500
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.
src/libgsystem | 2 +-
src/libostree/ostree-core.c | 37 +++++++++++++++++++++++++++----------
2 files changed, 28 insertions(+), 11 deletions(-)
---
diff --git a/src/libgsystem b/src/libgsystem
index c17376d..76d4b35 160000
--- a/src/libgsystem
+++ b/src/libgsystem
@@ -1 +1 @@
-Subproject commit c17376d4acbddfa1909d24167d3ce24531b3db1a
+Subproject commit 76d4b356378dc3549d402bfdd0bc953da7106f08
diff --git a/src/libostree/ostree-core.c b/src/libostree/ostree-core.c
index 3a8dc73..8d40319 100644
--- a/src/libostree/ostree-core.c
+++ b/src/libostree/ostree-core.c
@@ -540,28 +540,45 @@ ostree_content_file_parse (gboolean compressed,
struct stat stbuf;
ot_lobj GInputStream *file_input = NULL;
ot_lobj GInputStream *ret_input = NULL;
- ot_lobj GFileInfo *content_file_info = NULL;
ot_lobj GFileInfo *ret_file_info = NULL;
ot_lvariant GVariant *ret_xattrs = NULL;
- file_input = (GInputStream*)gs_file_read_noatime (content_path, cancellable, error);
- if (!file_input)
- goto out;
-
- if (fstat (g_file_descriptor_based_get_fd ((GFileDescriptorBased*)file_input), &stbuf) < 0)
+ if (out_input)
{
- ot_util_set_error_from_errno (error, errno);
- goto out;
+ file_input = (GInputStream*)gs_file_read_noatime (content_path, cancellable, error);
+ if (!file_input)
+ goto out;
+
+ if (fstat (g_file_descriptor_based_get_fd ((GFileDescriptorBased*)file_input), &stbuf) < 0)
+ {
+ ot_util_set_error_from_errno (error, errno);
+ goto out;
+ }
+
+ length = stbuf.st_size;
}
+ else
+ {
+ GMappedFile *mmaped;
+ GBytes *bytes;
- length = stbuf.st_size;
+ 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,
out_input ? &ret_input : NULL,
&ret_file_info, &ret_xattrs,
cancellable, error))
goto out;
-
+
ret = TRUE;
ot_transfer_out_value (out_input, &ret_input);
ot_transfer_out_value (out_file_info, &ret_file_info);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]