gnome-vfs performance patch



[ Sorry here's the same email with the patch in unified diff format ]

gnome-vfs gurus:

I did analysis of nautilus startup time with the Forte Performance
Analysis Tools and found the following:

nautilus: 3.210 seconds total user time, 30.850 seconds total system time

   5.620 system seconds spent in this stacktrace:
   
      gnome_vfs_module_callback_use_stack_info
         g_hash_table_foreach
            static function
               g_strdup
                  g_malloc

I have worked with Michael Meeks to generate the attached "vfs-speedup.pat"
patch.  This patch removes the need for copying default callback functions
in gnome_vfs_module_callback_get_stack_info.  This function is in the file
gnome-vfs/libgnomevfs/gnoem-vfs-module-callback.c.

Note that the function gnome_vfs_module_callback_invoke in the same file
is the only one that accesses the callback hashes.  It already will pull
the callback from the default if it doesn't find it in the private thread
memory (aka callback_stacks_key or async_callback_stacks_key).

On gnome-hackers Michael Meeks pointed out that "We should not copy the
default authentication callbacks; if someone is relying on the timing of
exactly when they set the default callback for a certain op [ NB. it can't
be un-set etc. ], then they're smoking crack and deserve oddness."

I have tested this patch with gnome-vfs/test/test-callback, the only
test which tests the affected authentication code.  As an aside, I found
it annoying that this test requires that the username/password be
hardcoded in the .c file.

I verified that everything worked okay.  I put print statements
in gnome_vfs_module_invoke, gnome_vfs_module_callback_set_default,
gnome_vfs_module_callback_get_stack_info, and
gnome_vfs_module_callback_use_stack_info.  With these print statements
in place, I verified that the values before and after applying the patch
were all reasonable.  The diff file is simply a diff between the before
and after files.  You can see that the only differences are:

   + default callback's aren't being copied into stack_info by the 
     dispatch thread.
   + default callback's aren't being pushed from the stack_info by
     the execute thread.
   + Some of the callbacks in gnome_vfs_module_invoke are being 
     found in the default rather than in stack_info
     
All of this is as expected.  According to Forte Analyzer, the startup
time of Nautilus is faster, and is no longer spending any time in
g_hash_table_foreach.

Can this patch be put back to gnome-vfs?  I'm not subscribed to this
alias, so please cc: me on any emails about this.  Thanks.

Brian 
Index: gnome-vfs/libgnomevfs/gnome-vfs-module-callback.c
===================================================================
RCS file: /cvs/GNOME-RE/gnome-vfs/libgnomevfs/gnome-vfs-module-callback.c,v
retrieving revision 1.4.2.1
diff -u -p -r1.4.2.1 gnome-vfs-module-callback.c
--- gnome-vfs/libgnomevfs/gnome-vfs-module-callback.c	2002/07/16 18:44:02	1.4.2.1
+++ gnome-vfs/libgnomevfs/gnome-vfs-module-callback.c	2002/10/21 11:25:57
@@ -339,17 +339,6 @@ copy_one_callback_to_stack (gpointer key
 	push_callback_into_stack_table (table, callback_name, callback);
 }
 
-static GHashTable *
-duplicate_callback_table (GHashTable *table)
-{
-	GHashTable *copy;
-	
-	copy = g_hash_table_new (g_str_hash, g_str_equal);
-	g_hash_table_foreach (table, copy_one_callback, copy);
-	
-	return copy;
-}
-
 static void
 copy_callback_stack_tops (GHashTable *source, 
 			  GHashTable *target)
@@ -940,11 +929,11 @@ gnome_vfs_module_callback_get_stack_info
 	GnomeVFSModuleCallbackStackInfo *stack_info;
 
 	stack_info = g_new (GnomeVFSModuleCallbackStackInfo, 1);
+	stack_info->current_callbacks = g_hash_table_new (g_str_hash, g_str_equal);
+	stack_info->current_async_callbacks = g_hash_table_new (g_str_hash, g_str_equal);
 
 	g_static_mutex_lock (&callback_table_lock);
 	initialize_global_if_needed ();
-	stack_info->current_callbacks = duplicate_callback_table (default_callbacks);
-	stack_info->current_async_callbacks = duplicate_callback_table (default_async_callbacks);
 	g_static_mutex_unlock (&callback_table_lock);
 
 	initialize_per_thread_if_needed ();
##### In gnome_vfs_module_invoke, looking for http:send-additional-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:received-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for simple-authentication
   ##### Not found
##### gnome_vfs_module_callback_set_default - simple-authentication
   ##### Inserting callback simple-authentication into table
##### In gnome_vfs_module_callback_get_stack_info, copying defaults
   ##### Inserting callback simple-authentication into table
##### In gnome_vfs_module_callback_get_stack_info, copying private
##### In gnome_vfs_module_callback_use_stack_info
   ##### Pushing callback simple-authentication into stack table
##### In gnome_vfs_module_invoke, looking for http:send-additional-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:received-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for simple-authentication
   ##### Found
##### In gnome_vfs_module_invoke, looking for http:send-additional-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:received-headers
   ##### Not found
##### gnome_vfs_async_module_clear_stacks
##### In gnome_vfs_module_callback_get_stack_info, copying defaults
   ##### Inserting callback simple-authentication into table
##### In gnome_vfs_module_callback_get_stack_info, copying private
##### In gnome_vfs_module_callback_use_stack_info
   ##### Pushing callback simple-authentication into stack table
##### gnome_vfs_async_module_clear_stacks
##### In gnome_vfs_module_invoke, looking for http:send-additional-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:received-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:send-additional-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:received-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:send-additional-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:received-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for simple-authentication
   ##### Found in default
##### In gnome_vfs_module_invoke, looking for http:send-additional-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:received-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:send-additional-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:received-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for simple-authentication
   ##### Found in default
##### In gnome_vfs_module_invoke, looking for http:send-additional-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:received-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:send-additional-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:received-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:send-additional-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:received-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for simple-authentication
   ##### Found in default
##### gnome_vfs_module_callback_push - simple-authentication
   ##### Pushing callback simple-authentication into stack table
##### In gnome_vfs_module_callback_get_stack_info, copying defaults
   ##### Inserting callback simple-authentication into table
##### In gnome_vfs_module_callback_get_stack_info, copying private
   ##### Inserting callback simple-authentication into table
##### gnome_vfs_module_callback_pop - simple-authentication
##### In gnome_vfs_module_callback_use_stack_info
   ##### Pushing callback simple-authentication into stack table
##### In gnome_vfs_module_invoke, looking for http:send-additional-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:received-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for simple-authentication
   ##### Found
##### In gnome_vfs_module_invoke, looking for http:send-additional-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:received-headers
   ##### Not found
##### gnome_vfs_async_module_clear_stacks
##### In gnome_vfs_module_callback_get_stack_info, copying defaults
   ##### Inserting callback simple-authentication into table
##### In gnome_vfs_module_callback_get_stack_info, copying private
##### In gnome_vfs_module_callback_use_stack_info
   ##### Pushing callback simple-authentication into stack table
##### gnome_vfs_async_module_clear_stacks
##### In gnome_vfs_module_invoke, looking for http:send-additional-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:received-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for simple-authentication
   ##### Not found
##### gnome_vfs_module_callback_set_default - simple-authentication
   ##### Inserting callback simple-authentication into table
##### In gnome_vfs_module_callback_get_stack_info, copying private
##### In gnome_vfs_module_callback_use_stack_info
##### In gnome_vfs_module_invoke, looking for http:send-additional-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:received-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for simple-authentication
   ##### Found in default
##### In gnome_vfs_module_invoke, looking for http:send-additional-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:received-headers
   ##### Not found
##### gnome_vfs_async_module_clear_stacks
##### In gnome_vfs_module_callback_get_stack_info, copying private
##### In gnome_vfs_module_callback_use_stack_info
##### gnome_vfs_async_module_clear_stacks
##### In gnome_vfs_module_invoke, looking for http:send-additional-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:received-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:send-additional-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:received-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:send-additional-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:received-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for simple-authentication
   ##### Found in default
##### In gnome_vfs_module_invoke, looking for http:send-additional-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:received-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:send-additional-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:received-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for simple-authentication
   ##### Found in default
##### In gnome_vfs_module_invoke, looking for http:send-additional-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:received-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:send-additional-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:received-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:send-additional-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:received-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for simple-authentication
   ##### Found in default
##### gnome_vfs_module_callback_push - simple-authentication
   ##### Pushing callback simple-authentication into stack table
##### In gnome_vfs_module_callback_get_stack_info, copying private
   ##### Inserting callback simple-authentication into table
##### gnome_vfs_module_callback_pop - simple-authentication
##### In gnome_vfs_module_callback_use_stack_info
   ##### Pushing callback simple-authentication into stack table
##### In gnome_vfs_module_invoke, looking for http:send-additional-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:received-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for simple-authentication
   ##### Found
##### In gnome_vfs_module_invoke, looking for http:send-additional-headers
   ##### Not found
##### In gnome_vfs_module_invoke, looking for http:received-headers
   ##### Not found
##### gnome_vfs_async_module_clear_stacks
##### In gnome_vfs_module_callback_get_stack_info, copying private
##### In gnome_vfs_module_callback_use_stack_info
##### gnome_vfs_async_module_clear_stacks
9,10d8
< ##### In gnome_vfs_module_callback_get_stack_info, copying defaults
<    ##### Inserting callback simple-authentication into table
13d10
<    ##### Pushing callback simple-authentication into stack table
19c16
<    ##### Found
---
>    ##### Found in default
25,26d21
< ##### In gnome_vfs_module_callback_get_stack_info, copying defaults
<    ##### Inserting callback simple-authentication into table
29d23
<    ##### Pushing callback simple-authentication into stack table
71,72d64
< ##### In gnome_vfs_module_callback_get_stack_info, copying defaults
<    ##### Inserting callback simple-authentication into table
89,90d80
< ##### In gnome_vfs_module_callback_get_stack_info, copying defaults
<    ##### Inserting callback simple-authentication into table
93d82
<    ##### Pushing callback simple-authentication into stack table


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]