[gegl] gegl: make default tile cache size depend on system RAM
- From: Øyvind "pippin" Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] gegl: make default tile cache size depend on system RAM
- Date: Sat, 26 Jan 2019 02:03:11 +0000 (UTC)
commit be8cd9eff3b82177123a39b545b9c6f36fdf6190
Author: Øyvind Kolås <pippin gimp org>
Date: Sat Jan 26 01:42:34 2019 +0100
gegl: make default tile cache size depend on system RAM
Desire to use 50% of RAM, if this is not available settle for
freeram+bufferram size, if this is less than 512mb, settle for
512mb. On other platforms the new default is 1GB.
gegl/gegl-config.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 47 insertions(+), 1 deletion(-)
---
diff --git a/gegl/gegl-config.c b/gegl/gegl-config.c
index ef705b88e..fd243e51e 100644
--- a/gegl/gegl-config.c
+++ b/gegl/gegl-config.c
@@ -30,6 +30,10 @@
#include "opencl/gegl-cl.h"
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
G_DEFINE_TYPE (GeglConfig, gegl_config, G_TYPE_OBJECT)
static GObjectClass * parent_class = NULL;
@@ -210,12 +214,54 @@ gegl_config_class_init (GeglConfigClass *klass)
0, G_MAXINT, 128,
G_PARAM_READWRITE));
+ {
+ long default_tile_cache_size = 1024l * 1024 * 1024;
+ long mem_total = default_tile_cache_size;
+ long mem_min = 512 << 20; // 512mb
+ long mem_available = mem_min;
+#ifdef G_OS_WIN32
+#ifdef G_OS_WIN32
+# if defined(_MSC_VER) && (_MSC_VER <= 1200)
+ MEMORYSTATUS memory_status;
+ memory_status.dwLength = sizeof (memory_status);
+
+ GlobalMemoryStatus (&memory_status);
+ mem_total = memory_status.dwTotalPhys;
+ mem_available = memory_status.dwAvailPhys;
+# else
+ /* requires w2k and newer SDK than provided with msvc6 */
+ MEMORYSTATUSEX memory_status;
+
+ memory_status.dwLength = sizeof (memory_status);
+
+ if (GlobalMemoryStatusEx (&memory_status))
+ {
+ mem_total = memory_status.ullTotalPhys;
+ mem_available = memory_status.ullAvailPhys;
+ }
+# endif
+#endif
+
+#else
+ mem_total = sysconf (_SC_PHYS_PAGES) * sysconf (_SC_PAGESIZE);
+ mem_available = sysconf (_SC_AVPHYS_PAGES) * sysconf (_SC_PAGESIZE);
+#endif
+
+ default_tile_cache_size = mem_total;
+ if (default_tile_cache_size > mem_available)
+ {
+ default_tile_cache_size = mem_available;
+ }
+ if (default_tile_cache_size < mem_min)
+ default_tile_cache_size = mem_min;
+
g_object_class_install_property (gobject_class, PROP_TILE_CACHE_SIZE,
g_param_spec_uint64 ("tile-cache-size",
"Tile Cache size",
"size of tile cache in bytes",
- 0, G_MAXUINT64, 512 * 1024 * 1024,
+ 0, G_MAXUINT64, default_tile_cache_size,
G_PARAM_READWRITE));
+ }
g_object_class_install_property (gobject_class, PROP_CHUNK_SIZE,
g_param_spec_int ("chunk-size",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]