+2006-07-04 Jan Schmidt <thaytan@mad.scientist.com>
+
+ * plugins/elements/gstfilesrc.c: (gst_file_src_class_init),
+ (gst_file_src_init), (gst_file_src_set_property),
+ (gst_file_src_get_property), (gst_file_src_map_region):
+ * plugins/elements/gstfilesrc.h:
+ Add "sequential" property, off by default, to use madvise and hint
+ to the kernel that sequential access is desired.
+ Touch all retrieved pages by default to ensure they are pulled
+ into memory. (Closes #345720)
+
2006-07-03 Wim Taymans <wim@fluendo.com>
* docs/design/part-block.txt:
#define DEFAULT_BLOCKSIZE 4*1024
#define DEFAULT_MMAPSIZE 4*1024*1024
-#define DEFAULT_TOUCH FALSE
+#define DEFAULT_TOUCH TRUE
#define DEFAULT_USEMMAP TRUE
+#define DEFAULT_SEQUENTIAL FALSE
enum
{
ARG_LOCATION,
ARG_FD,
ARG_MMAPSIZE,
+ ARG_SEQUENTIAL,
ARG_TOUCH,
ARG_USEMMAP
};
g_param_spec_boolean ("use-mmap", "Use mmap to read data",
"Whether to use mmap. FALSE to force normal read() calls",
DEFAULT_USEMMAP, G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, ARG_SEQUENTIAL,
+ g_param_spec_boolean ("sequential", "Optimise for sequential mmap access",
+ "Whether to use madvise to hint to the kernel that access to "
+ "mmap pages will be sequential",
+ DEFAULT_SEQUENTIAL, G_PARAM_READWRITE));
gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_file_src_finalize);
src->mapbuf = NULL;
src->mapsize = DEFAULT_MMAPSIZE; /* default is 4MB */
src->use_mmap = DEFAULT_USEMMAP;
+ src->sequential = DEFAULT_SEQUENTIAL;
src->is_regular = FALSE;
}
src->touch = g_value_get_boolean (value);
g_object_notify (G_OBJECT (src), "touch");
break;
+ case ARG_SEQUENTIAL:
+ src->sequential = g_value_get_boolean (value);
+ g_object_notify (G_OBJECT (src), "sequential");
+ break;
case ARG_USEMMAP:
src->use_mmap = g_value_get_boolean (value);
g_object_notify (G_OBJECT (src), "use-mmap");
case ARG_TOUCH:
g_value_set_boolean (value, src->touch);
break;
+ case ARG_SEQUENTIAL:
+ g_value_set_boolean (value, src->sequential);
+ break;
case ARG_USEMMAP:
g_value_set_boolean (value, src->use_mmap);
break;
GST_MMAP_BUFFER (buf)->filesrc = src;
#ifdef MADV_SEQUENTIAL
- /* madvise to tell the kernel what to do with it */
- if (madvise (mmapregion, size, MADV_SEQUENTIAL) < 0) {
- GST_WARNING_OBJECT (src, "warning: madvise failed: %s", strerror (errno));
+ if (src->sequential) {
+ /* madvise to tell the kernel what to do with it */
+ if (madvise (mmapregion, size, MADV_SEQUENTIAL) < 0) {
+ GST_WARNING_OBJECT (src, "warning: madvise failed: %s", strerror (errno));
+ }
}
#endif