From 8269a798019138ced2974bccc52cea277ca41faa Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 1 Mar 2013 09:44:19 +0000 Subject: [PATCH 1/2] vipsthumbnail sizes cache better the vipsthumbnail cache could be too small on many-cpu machines, size it more intelligently --- ChangeLog | 3 ++- tools/vipsthumbnail.c | 28 +++++++++++++++------------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 41100f3a..1e8bfbf9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,7 +4,8 @@ - fix another dzsave corner-case (thanks Martin) - neater output for "header" - added VIPS_META_LOADER: record the loader name -= header displays this hint += header displays this loader hint +- vipsthumbnail is better at cache sizing 31/8/12 started 7.31.0 - redone im_Lab2XYZ(), im_XYZ2Lab(), im_Lab2LCh(), im_LCh2Lab(), im_UCS2LCh, diff --git a/tools/vipsthumbnail.c b/tools/vipsthumbnail.c index a04d333c..99fe3d07 100644 --- a/tools/vipsthumbnail.c +++ b/tools/vipsthumbnail.c @@ -157,6 +157,9 @@ shrink_factor( IMAGE *in, IMAGE *out, VipsImage **s = (VipsImage **) vips_object_local_array( VIPS_OBJECT( out ), 1 ); IMAGE *x; + int tile_width; + int tile_height; + int nlines; if( im_open_local_array( out, t, 9, "thumbnail", "p" ) ) return( -1 ); @@ -181,9 +184,10 @@ shrink_factor( IMAGE *in, IMAGE *out, x = t[1]; } - /* Shrink! - * - * We want to make sure we read the image sequentially. + if( im_shrink( x, t[2], shrink, shrink ) ) + return( -1 ); + + /* We want to make sure we read the image sequentially. * However, the convolution we may be doing later will force us * into SMALLTILE or maybe FATSTRIP mode and that will break * sequentiality. @@ -191,13 +195,14 @@ shrink_factor( IMAGE *in, IMAGE *out, * So ... read into a cache where tiles are scanlines, and make sure * we keep enough scanlines to be able to serve a line of tiles. */ - if( im_shrink( x, t[2], shrink, shrink ) || - vips_tilecache( t[2], &s[0], - "tile_width", t[2]->Xsize, - "tile_height", 1, - "max_tiles", VIPS__TILE_HEIGHT * 2, - "strategy", VIPS_CACHE_SEQUENTIAL, - NULL ) || + vips_get_tile_size( t[2], + &tile_width, &tile_height, &nlines ); + if( vips_tilecache( t[2], &s[0], + "tile_width", t[2]->Xsize, + "tile_height", 1, + "max_tiles", nlines * 2, + "strategy", VIPS_CACHE_SEQUENTIAL, + NULL ) || im_affinei_all( s[0], t[4], interp, residual, 0, 0, residual, 0, 0 ) ) return( -1 ); @@ -256,9 +261,6 @@ shrink_factor( IMAGE *in, IMAGE *out, if( verbose ) printf( "deleting profile from output image\n" ); - /* Only try to remove if it exists to avoid extra error - * messages. - */ if( im_meta_get_typeof( x, IM_META_ICC_NAME ) && !im_meta_remove( x, IM_META_ICC_NAME ) ) return( -1 ); From ae27de5140dfecdd3466cfa290a306fcd80fdc99 Mon Sep 17 00:00:00 2001 From: John Cupitt Date: Fri, 1 Mar 2013 10:29:01 +0000 Subject: [PATCH 2/2] more granular cache for tiny speed up --- tools/vipsthumbnail.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/vipsthumbnail.c b/tools/vipsthumbnail.c index 99fe3d07..cba3257c 100644 --- a/tools/vipsthumbnail.c +++ b/tools/vipsthumbnail.c @@ -199,8 +199,8 @@ shrink_factor( IMAGE *in, IMAGE *out, &tile_width, &tile_height, &nlines ); if( vips_tilecache( t[2], &s[0], "tile_width", t[2]->Xsize, - "tile_height", 1, - "max_tiles", nlines * 2, + "tile_height", 10, + "max_tiles", (nlines * 2) / 10, "strategy", VIPS_CACHE_SEQUENTIAL, NULL ) || im_affinei_all( s[0], t[4],