fix --vips-cache-max etc.

--vips-cache-max, --vips-cache-max-memory and --vips-cache-max-files were not
working and probably hadn't been for a while

vipsthumbnail.c turns off the operation cache, it's not useful for
the same operation repeated across many files
This commit is contained in:
John Cupitt 2017-01-10 14:12:24 +00:00
parent 8bbba73d73
commit c5e675f7db
6 changed files with 61 additions and 23 deletions

View File

@ -19,6 +19,7 @@
VIPS_LIBRARY_AGE
- better support for bscale / bzero in fits images
- deprecate vips_warn() / vips_info(); use g_warning() / g_info() instead
- fix --vips-cache-max etc.
8/12/16 started 8.4.5
- allow libgsf-1.14.26 to help centos, thanks tdiprima

View File

@ -94,11 +94,6 @@ extern int vips__info;
*/
extern char *vips__disc_threshold;
/* Cache size settings.
*/
extern char *vips__cache_max;
extern char *vips__cache_max_mem;
extern char *vips__cache_max_files;
extern gboolean vips__cache_dump;
extern gboolean vips__cache_trace;

View File

@ -67,9 +67,6 @@
/* Set by GOption from the command line, eg. "12m".
*/
char *vips__cache_max = NULL;
char *vips__cache_max_mem = NULL;
char *vips__cache_max_files = NULL;
gboolean vips__cache_dump = FALSE;
gboolean vips__cache_trace = FALSE;
@ -456,18 +453,6 @@ vips__cache_init( void )
vips_cache_table = g_hash_table_new(
(GHashFunc) vips_operation_hash,
(GEqualFunc) vips_operation_equal );
if( vips__cache_max )
vips_cache_max =
vips__parse_size( vips__cache_max );
if( vips__cache_max_mem )
vips_cache_max_mem =
vips__parse_size( vips__cache_max_mem );
if( vips__cache_max_files )
vips_cache_max_files =
vips__parse_size( vips__cache_max_files );
}
}

View File

@ -614,6 +614,33 @@ vips_lib_version_cb( const gchar *option_name, const gchar *value,
exit( 0 );
}
static gboolean
vips_cache_max_cb( const gchar *option_name, const gchar *value,
gpointer data, GError **error )
{
vips_cache_set_max( vips__parse_size( value ) );
return( TRUE );
}
static gboolean
vips_cache_max_memory_cb( const gchar *option_name, const gchar *value,
gpointer data, GError **error )
{
vips_cache_set_max_mem( vips__parse_size( value ) );
return( TRUE );
}
static gboolean
vips_cache_max_files_cb( const gchar *option_name, const gchar *value,
gpointer data, GError **error )
{
vips_cache_set_max_files( vips__parse_size( value ) );
return( TRUE );
}
static GOptionEntry option_entries[] = {
{ "vips-info", 0, G_OPTION_FLAG_HIDDEN | G_OPTION_FLAG_NO_ARG,
G_OPTION_ARG_CALLBACK, (gpointer) &vips_lib_info_cb,
@ -652,13 +679,13 @@ static GOptionEntry option_entries[] = {
G_OPTION_ARG_NONE, &vips__vector_enabled,
N_( "disable vectorised versions of operations" ), NULL },
{ "vips-cache-max", 0, 0,
G_OPTION_ARG_STRING, &vips__cache_max,
G_OPTION_ARG_CALLBACK, (gpointer) &vips_cache_max_cb,
N_( "cache at most N operations" ), "N" },
{ "vips-cache-max-memory", 0, 0,
G_OPTION_ARG_STRING, &vips__cache_max_mem,
G_OPTION_ARG_CALLBACK, (gpointer) &vips_cache_max_memory_cb,
N_( "cache at most N bytes in memory" ), "N" },
{ "vips-cache-max-files", 0, 0,
G_OPTION_ARG_STRING, &vips__cache_max_files,
G_OPTION_ARG_CALLBACK, (gpointer) &vips_cache_max_files_cb,
N_( "allow at most N open files" ), "N" },
{ "vips-cache-trace", 0, 0,
G_OPTION_ARG_NONE, &vips__cache_trace,

View File

@ -106,6 +106,30 @@ typedef struct _VipsThumbnailClass {
G_DEFINE_ABSTRACT_TYPE( VipsThumbnail, vips_thumbnail, VIPS_TYPE_OPERATION );
static void
vips_thumbnail_dispose( GObject *gobject )
{
#ifdef DEBUG
printf( "vips_thumbnail_dispose: " );
vips_object_print_name( VIPS_OBJECT( gobject ) );
printf( "\n" );
#endif /*DEBUG*/
G_OBJECT_CLASS( vips_thumbnail_parent_class )->dispose( gobject );
}
static void
vips_thumbnail_finalize( GObject *gobject )
{
#ifdef DEBUG
printf( "vips_thumbnail_finalize: " );
vips_object_print_name( VIPS_OBJECT( gobject ) );
printf( "\n" );
#endif /*DEBUG*/
G_OBJECT_CLASS( vips_thumbnail_parent_class )->finalize( gobject );
}
/* Calculate the shrink factor, taking into account auto-rotate, the fit mode,
* and so on.
*/
@ -470,6 +494,8 @@ vips_thumbnail_class_init( VipsThumbnailClass *class )
GObjectClass *gobject_class = G_OBJECT_CLASS( class );
VipsObjectClass *vobject_class = VIPS_OBJECT_CLASS( class );
gobject_class->dispose = vips_thumbnail_dispose;
gobject_class->finalize = vips_thumbnail_finalize;
gobject_class->set_property = vips_object_set_property;
gobject_class->get_property = vips_object_get_property;

View File

@ -265,6 +265,10 @@ main( int argc, char **argv )
textdomain( GETTEXT_PACKAGE );
setlocale( LC_ALL, "" );
/* The operation cache is not useful for processing many files.
vips_cache_set_max( 0 );
*/
/* On Windows, argv is ascii-only .. use this to get a utf-8 version of
* the args.
*/