add --vips-cache-trace
and rename cache-print as cache-dump
This commit is contained in:
parent
c190c8e660
commit
d5034b0485
18
TODO
18
TODO
@ -1,12 +1,24 @@
|
||||
- cache tracing is very handy, maybe make the VIPS_DEBUG macros in cache.c
|
||||
into glog things
|
||||
into glog things, or have a --vips-cache-log flag?
|
||||
|
||||
test this
|
||||
|
||||
- Vips.Image has members like chain, __subclasshook__ etc etc, are we
|
||||
really subclassing it correctly?
|
||||
|
||||
- grep for other vips_class_find() problems: do we use it for simple class
|
||||
lookup anywhere else?
|
||||
- get cli arg hooks working
|
||||
|
||||
- add support for constants
|
||||
|
||||
- add __add__ etc overloads
|
||||
|
||||
- vips options: lex entire string to an array of tokens, noting the position
|
||||
of each
|
||||
|
||||
if the final token is a right-bracket, count brackets leftwards to get the
|
||||
matching start bracket
|
||||
|
||||
parse options from that point
|
||||
|
||||
|
||||
|
||||
|
@ -80,7 +80,8 @@ extern char *vips__disc_threshold;
|
||||
extern char *vips__cache_max;
|
||||
extern char *vips__cache_max_mem;
|
||||
extern char *vips__cache_max_files;
|
||||
extern gboolean vips__cache_print;
|
||||
extern gboolean vips__cache_dump;
|
||||
extern gboolean vips__cache_trace;
|
||||
|
||||
typedef int (*im__fftproc_fn)( VipsImage *, VipsImage *, VipsImage * );
|
||||
|
||||
|
@ -56,7 +56,7 @@ typedef gboolean (*VipsOperationBuildFn)( VipsObject * );
|
||||
typedef struct _VipsOperation {
|
||||
VipsObject parent_instance;
|
||||
|
||||
/* When we added this oepration to cache .. used to find LRU for
|
||||
/* When we added this operation to cache .. used to find LRU for
|
||||
* flush.
|
||||
*/
|
||||
int time;
|
||||
|
@ -71,7 +71,8 @@
|
||||
char *vips__cache_max = NULL;
|
||||
char *vips__cache_max_mem = NULL;
|
||||
char *vips__cache_max_files = NULL;
|
||||
gboolean vips__cache_print = FALSE;
|
||||
gboolean vips__cache_dump = FALSE;
|
||||
gboolean vips__cache_trace = FALSE;
|
||||
|
||||
/* Max number of cached operations.
|
||||
*/
|
||||
@ -411,7 +412,7 @@ vips_cache_init( void )
|
||||
}
|
||||
|
||||
static void
|
||||
vips_cache_print( void )
|
||||
vips_cache_dump( void )
|
||||
{
|
||||
if( vips_cache_table ) {
|
||||
GHashTableIter iter;
|
||||
@ -488,8 +489,8 @@ void
|
||||
vips_cache_drop_all( void )
|
||||
{
|
||||
if( vips_cache_table ) {
|
||||
if( vips__cache_print )
|
||||
vips_cache_print();
|
||||
if( vips__cache_dump )
|
||||
vips_cache_dump();
|
||||
|
||||
/* We can't modify the hash in the callback from
|
||||
* g_hash_table_foreach() and friends. Repeatedly drop the
|
||||
@ -617,7 +618,10 @@ vips_cache_operation_buildp( VipsOperation **operation )
|
||||
vips_cache_trim();
|
||||
|
||||
if( (hit = g_hash_table_lookup( vips_cache_table, *operation )) ) {
|
||||
VIPS_DEBUG_MSG( "\thit %p\n", hit );
|
||||
if( vips__cache_trace ) {
|
||||
printf( "hit %p ", hit );
|
||||
vips_object_print_summary( VIPS_OBJECT( *operation ) );
|
||||
}
|
||||
|
||||
/* Ref before unref in case *operation == hit.
|
||||
*/
|
||||
@ -627,7 +631,10 @@ vips_cache_operation_buildp( VipsOperation **operation )
|
||||
*operation = hit;
|
||||
}
|
||||
else {
|
||||
VIPS_DEBUG_MSG( "\tmiss, build and add\n" );
|
||||
if( vips__cache_trace ) {
|
||||
printf( "miss + build %p ", hit );
|
||||
vips_object_print_summary( VIPS_OBJECT( *operation ) );
|
||||
}
|
||||
|
||||
if( vips_object_build( VIPS_OBJECT( *operation ) ) )
|
||||
return( -1 );
|
||||
|
@ -395,9 +395,12 @@ static GOptionEntry option_entries[] = {
|
||||
{ "vips-cache-max-files", 'l', 0,
|
||||
G_OPTION_ARG_STRING, &vips__cache_max_files,
|
||||
N_( "allow at most N open files" ), "N" },
|
||||
{ "vips-cache-print", 'r', 0,
|
||||
G_OPTION_ARG_NONE, &vips__cache_print,
|
||||
N_( "print operation cache on exit" ), NULL },
|
||||
{ "vips-cache-trace", 'c', 0,
|
||||
G_OPTION_ARG_NONE, &vips__cache_trace,
|
||||
N_( "trace operation cache" ), NULL },
|
||||
{ "vips-cache-dump", 'r', 0,
|
||||
G_OPTION_ARG_NONE, &vips__cache_dump,
|
||||
N_( "dump operation cache on exit" ), NULL },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import logging
|
||||
import sys
|
||||
|
||||
from gi.repository import GLib
|
||||
from gi.repository import GObject
|
||||
@ -151,3 +152,6 @@ class Image(Vips.Image):
|
||||
logging.debug('vipsimage: __getattr__ %s' % name)
|
||||
return lambda *args, **kwargs: _call_instance(self, name, args, kwargs)
|
||||
|
||||
# start up vips!
|
||||
Vips.init(sys.argv[0])
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user