gegl r2223 - in trunk: . gegl gegl/buffer
- From: ok svn gnome org
- To: svn-commits-list gnome org
- Subject: gegl r2223 - in trunk: . gegl gegl/buffer
- Date: Wed, 23 Apr 2008 22:47:04 +0100 (BST)
Author: ok
Date: Wed Apr 23 21:47:04 2008
New Revision: 2223
URL: http://svn.gnome.org/viewvc/gegl?rev=2223&view=rev
Log:
* gegl/buffer/gegl-tile-handler-cache.c: roughly obey requested cache
size.
* gegl/gegl-debug.h: added CACHE debuging domain.
Modified:
trunk/ChangeLog
trunk/gegl/buffer/gegl-tile-handler-cache.c
trunk/gegl/gegl-debug.h
Modified: trunk/gegl/buffer/gegl-tile-handler-cache.c
==============================================================================
--- trunk/gegl/buffer/gegl-tile-handler-cache.c (original)
+++ trunk/gegl/buffer/gegl-tile-handler-cache.c Wed Apr 23 21:47:04 2008
@@ -21,20 +21,22 @@
#include <glib.h>
#include <glib-object.h>
+#include "gegl-config.h"
#include "../gegl-types.h"
#include "gegl-buffer.h"
#include "gegl-buffer-private.h"
#include "gegl-tile.h"
#include "gegl-tile-handler-cache.h"
-
-/* FIXME: this global cache should have configurable size and wash percentage */
+#include "gegl-debug.h"
static GQueue *cache_queue = NULL;
-static gint cache_size = 512;
static gint cache_wash_percentage = 20;
static gint cache_hits = 0;
static gint cache_misses = 0;
+static gint cache_total = 0; /* approximate amount of bytes stored */
+static gint clones_ones = 0; /* approximate amount of bytes stored */
+
struct _GeglTileHandlerCache
{
GeglTileHandler parent_instance;
@@ -123,10 +125,6 @@
GSList *iter;
cache = (GeglTileHandlerCache *) object;
- if (0)
- g_printerr ("Disposing tile-cache of size %i, hits: %i misses: %i hit percentage:%f)\n",
- cache_size, cache_hits, cache_misses,
- cache_hits * 100.0 / (cache_hits + cache_misses));
/* only throw out items belonging to this cache instance
(XXX: should probably have a local list for that)*/
@@ -137,7 +135,11 @@
{
item = iter->data;
if (item->tile)
- g_object_unref (item->tile);
+ {
+ cache_total -= item->tile->size;
+ clones_ones = 0; /* XXX */
+ g_object_unref (item->tile);
+ }
g_queue_remove (cache_queue, item);
g_slice_free (CacheItem, item);
}
@@ -157,7 +159,6 @@
GeglTileSource *source = GEGL_HANDLER (tile_store)->source;
GeglTile *tile = NULL;
- if(0)g_print ("\r%f%% hit:%i miss:%i %i]", cache_hits*100.0/(cache_hits+cache_misses), cache_hits, cache_misses, g_queue_get_length (cache_queue));
tile = gegl_tile_handler_cache_get_tile (cache, x, y, z);
if (tile)
@@ -270,7 +271,8 @@
{
GeglTile *last_dirty = NULL;
guint count = 0;
- gint wash_tiles = cache_wash_percentage * cache_size / 100;
+ gint length = g_queue_get_length (cache_queue);
+ gint wash_tiles = cache_wash_percentage * length / 100;
GList *link;
for (link = g_queue_peek_head_link (cache_queue); link; link = link->next)
@@ -280,7 +282,7 @@
count++;
if (!gegl_tile_is_stored (tile))
- if (count > cache_size - wash_tiles)
+ if (count > length - wash_tiles)
last_dirty = tile;
}
@@ -352,6 +354,7 @@
if (last_writable != NULL)
{
+ cache_total -= last_writable->tile->size;
g_object_unref (last_writable->tile);
g_slice_free (CacheItem, last_writable);
return TRUE;
@@ -381,6 +384,7 @@
item->handler == cache)
{
gegl_tile_void (tile);
+ cache_total -= item->tile->size;
g_object_unref (tile);
g_slice_free (CacheItem, item);
g_queue_delete_link (cache_queue, link);
@@ -404,15 +408,16 @@
item->x = x;
item->y = y;
item->z = z;
+ cache_total += item->tile->size;
g_queue_push_head (cache_queue, item);
count = g_queue_get_length (cache_queue);
- if (count > cache_size)
+ if (cache_total > gegl_config()->cache_size)
{
- gint to_remove = count - cache_size;
-
- while (--to_remove && gegl_tile_handler_cache_trim (cache)) ;
+ GEGL_NOTE(CACHE, "cache_total:%i > cache_size:%i\n", cache_total, gegl_config()->cache_size);
+ GEGL_NOTE(CACHE, "%f%% hit:%i miss:%i %i]", cache_hits*100.0/(cache_hits+cache_misses), cache_hits, cache_misses, g_queue_get_length (cache_queue));
+ gegl_tile_handler_cache_trim (cache);
}
}
Modified: trunk/gegl/gegl-debug.h
==============================================================================
--- trunk/gegl/gegl-debug.h (original)
+++ trunk/gegl/gegl-debug.h Wed Apr 23 21:47:04 2008
@@ -12,6 +12,7 @@
GEGL_DEBUG_BUFFER_SAVE = 1 << 2,
GEGL_DEBUG_TILE_BACKEND = 1 << 3,
GEGL_DEBUG_PROCESSOR = 1 << 4,
+ GEGL_DEBUG_CACHE = 1 << 5,
} GeglDebugFlag;
/* only compiled in from gegl-init.c but kept here to
@@ -21,6 +22,7 @@
#ifdef __GEGL_INIT_C
static const GDebugKey gegl_debug_keys[] = {
{ "process", GEGL_DEBUG_PROCESS},
+ { "cache", GEGL_DEBUG_CACHE},
{ "buffer-load", GEGL_DEBUG_BUFFER_LOAD},
{ "buffer-save", GEGL_DEBUG_BUFFER_SAVE},
{ "tile-backend", GEGL_DEBUG_TILE_BACKEND},
@@ -29,7 +31,8 @@
GEGL_DEBUG_BUFFER_LOAD|
GEGL_DEBUG_BUFFER_SAVE|
GEGL_DEBUG_TILE_BACKEND|
- GEGL_DEBUG_PROCESSOR},
+ GEGL_DEBUG_PROCESSOR|
+ GEGL_DEBUG_CACHE},
};
#endif /* GEGL_ENABLE_DEBUG */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]