Skip to content

Commit e01a90f

Browse files
committed
revise cache sizing
we had output buffers too large, input caches too small see https://github.com/jcupitt/libvips/issues/639
1 parent 38b6547 commit e01a90f

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

ChangeLog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
7/4/17 started 8.5.3
22
- more link fixing in docs
3+
- revise cache sizing again to help out of order errors under heavy load, thanks
4+
kleisauke
35

46
25/3/17 started 8.5.2
57
- better behaviour for truncated PNG files, thanks Yury

TODO

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
- add analytics tags to docs output
2-
31
- not sure about utf8 error messages on win
42

53
- strange:

libvips/conversion/tilecache.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,12 @@ vips_line_cache_build( VipsObject *object )
935935
vips_get_tile_size( block_cache->in,
936936
&tile_width, &tile_height, &n_lines );
937937
block_cache->tile_width = block_cache->in->Xsize;
938-
block_cache->max_tiles = 1 + 2 * n_lines / block_cache->tile_height;
938+
939+
/* Output has two buffers n_lines height, so 2 * n_lines is the maximum
940+
* non-locality from threading. Add another n_lines for conv / reducev
941+
* etc.
942+
*/
943+
block_cache->max_tiles = 3 * n_lines / block_cache->tile_height;
939944

940945
VIPS_DEBUG_MSG( "vips_line_cache_build: n_lines = %d\n",
941946
n_lines );

libvips/iofuncs/threadpool.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@
4848
*/
4949

5050
/*
51-
#define VIPS_DEBUG
5251
#define VIPS_DEBUG_RED
5352
#define DEBUG_OUT_OF_THREADS
53+
#define VIPS_DEBUG
5454
*/
5555

5656
#ifdef HAVE_CONFIG_H
@@ -1011,6 +1011,10 @@ vips__threadpool_init( void )
10111011
* Pick a tile size and a buffer height for this image and the current
10121012
* value of vips_concurrency_get(). The buffer height
10131013
* will always be a multiple of tile_height.
1014+
*
1015+
* The buffer height is the height of each buffer we fill in sink disc. Since
1016+
* we have two buffers, the largest range of input locality is twice the output
1017+
* buffer size, plus whatever margin we add for things like convolution.
10141018
*/
10151019
void
10161020
vips_get_tile_size( VipsImage *im,
@@ -1054,9 +1058,10 @@ vips_get_tile_size( VipsImage *im,
10541058
* to a multiple of tileheight.
10551059
*/
10561060
*n_lines = vips__tile_height *
1057-
(1 + nthr / VIPS_MAX( 1, im->Xsize / vips__tile_width )) * 2;
1058-
*n_lines = VIPS_MAX( *n_lines, vips__fatstrip_height * nthr * 2 );
1059-
*n_lines = VIPS_MAX( *n_lines, vips__thinstrip_height * nthr * 2 );
1061+
VIPS_MAX( 1,
1062+
nthr / VIPS_MAX( 1, im->Xsize / vips__tile_width ) );
1063+
*n_lines = VIPS_MAX( *n_lines, vips__fatstrip_height * nthr );
1064+
*n_lines = VIPS_MAX( *n_lines, vips__thinstrip_height * nthr );
10601065
*n_lines = VIPS_ROUND_UP( *n_lines, *tile_height );
10611066

10621067
/* We make this assumption in several places.

0 commit comments

Comments
 (0)