more UNBUF fixes

try to keep compat better, remove the single-thread-first-tile idea
This commit is contained in:
John Cupitt 2017-02-21 16:53:48 +00:00
parent 959f412380
commit a4d3c2a754
10 changed files with 26 additions and 38 deletions

8
TODO
View File

@ -1,15 +1,9 @@
- seq no longer stalls ahead threads ... instead, we rely on sinkdisk
interlocks to limit how far ahead or behind threads can get
deprecate UNBUFFERED? it will probably not work now
remove single-thread-first-tile thing
the readbehind option to many loaders is no longer needed
do we need to restore the UNBUFFERED enum member to keep binary compat? we
need to make sure old code using UNBUFF now uses regular SEQ (and not RAND)
check pforeign.h

View File

@ -262,6 +262,7 @@ vips_sequential_init( VipsSequential *sequential )
sequential->lock = vips_g_mutex_new();
sequential->tile_height = 1;
sequential->error = 0;
sequential->access = VIPS_ACCESS_SEQUENTIAL;
}
/**

View File

@ -280,6 +280,7 @@ vips_tile_search_recycle( gpointer key, gpointer value, gpointer user_data )
break;
case VIPS_ACCESS_SEQUENTIAL:
case VIPS_ACCESS_SEQUENTIAL_UNBUFFERED:
if( tile->pos.top < search->topmost ) {
search->topmost = tile->pos.top;
search->tile = tile;

View File

@ -129,13 +129,10 @@ typedef enum {
typedef enum {
VIPS_ACCESS_RANDOM,
VIPS_ACCESS_SEQUENTIAL,
VIPS_ACCESS_SEQUENTIAL_UNBUFFERED,
VIPS_ACCESS_LAST
} VipsAccess;
/* Compat for a mode we used to support.
*/
#define VIPS_ACCESS_SEQUENTIAL_UNBUFFERED VIPS_ACCESS_SEQUENTIAL
struct _VipsImage;
struct _VipsRegion;

View File

@ -669,6 +669,7 @@ vips_access_get_type( void )
static const GEnumValue values[] = {
{VIPS_ACCESS_RANDOM, "VIPS_ACCESS_RANDOM", "random"},
{VIPS_ACCESS_SEQUENTIAL, "VIPS_ACCESS_SEQUENTIAL", "sequential"},
{VIPS_ACCESS_SEQUENTIAL_UNBUFFERED, "VIPS_ACCESS_SEQUENTIAL_UNBUFFERED", "sequential-unbuffered"},
{VIPS_ACCESS_LAST, "VIPS_ACCESS_LAST", "last"},
{0, NULL, NULL}
};

View File

@ -1816,6 +1816,7 @@ vips_object_set_argument_from_string( VipsObject *object,
if( g_type_is_a( otype, VIPS_TYPE_IMAGE ) ) {
VipsImage *out;
VipsOperationFlags flags;
VipsAccess access;
if( !value ) {
vips_object_no_value( object, name );
@ -1827,12 +1828,15 @@ vips_object_set_argument_from_string( VipsObject *object,
flags = vips_operation_get_flags(
VIPS_OPERATION( object ) );
/* Read the filename.
*/
if( flags &
(VIPS_OPERATION_SEQUENTIAL |
VIPS_OPERATION_SEQUENTIAL_UNBUFFERED) )
access = VIPS_ACCESS_SEQUENTIAL;
else
access = VIPS_ACCESS_RANDOM;
if( !(out = vips_image_new_from_file( value,
"access", flags & VIPS_OPERATION_SEQUENTIAL ?
VIPS_ACCESS_SEQUENTIAL : VIPS_ACCESS_RANDOM,
"access", access,
NULL )) )
return( -1 );
@ -1851,6 +1855,7 @@ vips_object_set_argument_from_string( VipsObject *object,
*/
VipsArrayImage *array_image;
VipsOperationFlags flags;
VipsAccess access;
if( !value ) {
vips_object_no_value( object, name );
@ -1862,9 +1867,15 @@ vips_object_set_argument_from_string( VipsObject *object,
flags = vips_operation_get_flags(
VIPS_OPERATION( object ) );
if( !(array_image = vips_array_image_new_from_string( value,
flags & VIPS_OPERATION_SEQUENTIAL ?
VIPS_ACCESS_SEQUENTIAL : VIPS_ACCESS_RANDOM )) )
if( flags &
(VIPS_OPERATION_SEQUENTIAL |
VIPS_OPERATION_SEQUENTIAL_UNBUFFERED) )
access = VIPS_ACCESS_SEQUENTIAL;
else
access = VIPS_ACCESS_RANDOM;
if( !(array_image =
vips_array_image_new_from_string( value, access )) )
return( -1 );
g_value_init( &gvalue, VIPS_TYPE_ARRAY_IMAGE );

View File

@ -548,12 +548,6 @@ typedef struct _VipsThreadpool {
/* Set by Allocate (via an arg) to indicate normal end of computation.
*/
gboolean stop;
/* Set by the first thread to hit allocate. The first work unit runs
* single-threaded to give loaders a change to get to the right spot
* in the input.
*/
gboolean done_first;
} VipsThreadpool;
/* Junk a thread.
@ -635,8 +629,7 @@ vips_thread_work_unit( VipsThread *thr )
return;
}
if( pool->done_first )
g_mutex_unlock( pool->allocate_lock );
g_mutex_unlock( pool->allocate_lock );
/* Process a work unit.
*/
@ -644,11 +637,6 @@ vips_thread_work_unit( VipsThread *thr )
thr->error = TRUE;
pool->error = TRUE;
}
if( !pool->done_first ) {
pool->done_first = TRUE;
g_mutex_unlock( pool->allocate_lock );
}
}
/* What runs as a thread ... loop, waiting to be told to do stuff.
@ -781,7 +769,6 @@ vips_threadpool_new( VipsImage *im )
vips_semaphore_init( &pool->tick, 0, "tick" );
pool->error = FALSE;
pool->stop = FALSE;
pool->done_first = FALSE;
/* If this is a tiny image, we won't need all nthr threads. Guess how
* many tiles we might need to cover the image and use that to limit

View File

@ -562,7 +562,7 @@ vips_reduceh_class_init( VipsReducehClass *reduceh_class )
vobject_class->description = _( "shrink an image horizontally" );
vobject_class->build = vips_reduceh_build;
operation_class->flags = VIPS_OPERATION_SEQUENTIAL_UNBUFFERED;
operation_class->flags = VIPS_OPERATION_SEQUENTIAL;
VIPS_ARG_DOUBLE( reduceh_class, "hshrink", 3,
_( "Hshrink" ),

View File

@ -895,7 +895,7 @@ vips_reducev_class_init( VipsReducevClass *reducev_class )
vobject_class->description = _( "shrink an image vertically" );
vobject_class->build = vips_reducev_build;
operation_class->flags = VIPS_OPERATION_SEQUENTIAL_UNBUFFERED;
operation_class->flags = VIPS_OPERATION_SEQUENTIAL;
VIPS_ARG_DOUBLE( reducev_class, "vshrink", 3,
_( "Vshrink" ),

View File

@ -631,8 +631,6 @@ vips_thumbnail_file_open( VipsThumbnail *thumbnail, int shrink, double scale )
{
VipsThumbnailFile *file = (VipsThumbnailFile *) thumbnail;
/* We can't use UNBUFERRED safely on very-many-core systems.
*/
if( shrink != 1 )
return( vips_image_new_from_file( file->filename,
"access", VIPS_ACCESS_SEQUENTIAL,
@ -795,8 +793,6 @@ vips_thumbnail_buffer_open( VipsThumbnail *thumbnail,
{
VipsThumbnailBuffer *buffer = (VipsThumbnailBuffer *) thumbnail;
/* We can't use UNBUFERRED safely on very-many-core systems.
*/
if( shrink != 1 )
return( vips_image_new_from_buffer(
buffer->buf->data, buffer->buf->length, "",