[gegl] buffer: in gegl-tile-alloc, limit number of tiles per block
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] buffer: in gegl-tile-alloc, limit number of tiles per block
- Date: Fri, 19 Jul 2019 17:17:23 +0000 (UTC)
commit fff84b3a42050a4aeeedde9f46966ef99979288b
Author: Ell <ell_se yahoo com>
Date: Fri Jul 19 19:54:49 2019 +0300
buffer: in gegl-tile-alloc, limit number of tiles per block
In gegl-tile-alloc, limit the number of tiles in a single block
(currently, to 1024 tiles). This sets an upper limit for block
overhead even when using a big tile cache, and, in particular,
avoids regularly falling back to single-tile allocations when the
cache size is much higher than memory size (see previous commit).
gegl/buffer/gegl-tile-alloc.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/gegl/buffer/gegl-tile-alloc.c b/gegl/buffer/gegl-tile-alloc.c
index 38c8e824e..5745bec9c 100644
--- a/gegl/buffer/gegl-tile-alloc.c
+++ b/gegl/buffer/gegl-tile-alloc.c
@@ -41,6 +41,7 @@
#define GEGL_TILE_BLOCK_BUFFER_OFFSET GEGL_ALIGN (sizeof (GeglTileBlock))
#define GEGL_TILE_BLOCK_SIZE_RATIO 0.01
+#define GEGL_TILE_BLOCK_MAX_BUFFERS 1024
#define GEGL_TILE_BLOCKS_PER_TRIM 10
#define GEGL_TILE_SENTINEL_BLOCK ((GeglTileBlock *) ~(guintptr) 0)
@@ -141,6 +142,7 @@ gegl_tile_block_new (GeglTileBlock * volatile *block_ptr,
GeglTileBuffer **next_buffer;
gsize block_size;
gsize buffer_size;
+ gsize n_buffers;
gint n_blocks;
gint i;
@@ -150,9 +152,14 @@ gegl_tile_block_new (GeglTileBlock * volatile *block_ptr,
GEGL_TILE_BLOCK_SIZE_RATIO);
block_size -= block_size % buffer_size;
- if (block_size <= buffer_size)
+ n_buffers = block_size / buffer_size;
+ n_buffers = MIN (n_buffers, GEGL_TILE_BLOCK_MAX_BUFFERS);
+
+ if (n_buffers <= 1)
return NULL;
+ block_size = n_buffers * buffer_size;
+
block = gegl_try_malloc (GEGL_TILE_BLOCK_BUFFER_OFFSET + block_size);
if (! block)
@@ -170,7 +177,7 @@ gegl_tile_block_new (GeglTileBlock * volatile *block_ptr,
buffer = block->head;
- for (i = block_size / buffer_size; i; i--)
+ for (i = n_buffers; i; i--)
{
buffer->block = block;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]