commit-gnue
[Top][All Lists]
Advanced

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

gnue/geas/src collectiondata.c geas-server.c ge...


From: Treshna Enterprises
Subject: gnue/geas/src collectiondata.c geas-server.c ge...
Date: Tue, 12 Jun 2001 17:47:47 -0700

CVSROOT:        /cvs
Module name:    gnue
Changes by:     Treshna Enterprises <address@hidden>    01/06/12 17:47:47

Modified files:
        geas/src       : collectiondata.c geas-server.c geas-server.h 
                         geas-skeleton.c objectlist.c 
        geas/src/objectcache: objectcache.c objectcache.h 
        geas/src/objectstore: objectstore.c objectstore.h 
                              objectstore_private.h postgresql.c 

Log message:
        Added more profiling code
        Speed increase: fixed collection.c to improve access speeds, and made
        access speed for an object constant (previously, in very large lists,
        later objects took much longer to process, making large lists very
        inefficient)

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/src/collectiondata.c.diff?cvsroot=OldCVS&tr1=1.24&tr2=1.25&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/src/geas-server.c.diff?cvsroot=OldCVS&tr1=1.102&tr2=1.103&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/src/geas-server.h.diff?cvsroot=OldCVS&tr1=1.48&tr2=1.49&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/src/geas-skeleton.c.diff?cvsroot=OldCVS&tr1=1.63&tr2=1.64&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/src/objectlist.c.diff?cvsroot=OldCVS&tr1=1.24&tr2=1.25&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/src/objectcache/objectcache.c.diff?cvsroot=OldCVS&tr1=1.52&tr2=1.53&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/src/objectcache/objectcache.h.diff?cvsroot=OldCVS&tr1=1.17&tr2=1.18&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/src/objectstore/objectstore.c.diff?cvsroot=OldCVS&tr1=1.66&tr2=1.67&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/src/objectstore/objectstore.h.diff?cvsroot=OldCVS&tr1=1.21&tr2=1.22&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/src/objectstore/objectstore_private.h.diff?cvsroot=OldCVS&tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/src/objectstore/postgresql.c.diff?cvsroot=OldCVS&tr1=1.4&tr2=1.5&r1=text&r2=text

Patches:
Index: gnue/geas/src/collectiondata.c
diff -u gnue/geas/src/collectiondata.c:1.24 gnue/geas/src/collectiondata.c:1.25
--- gnue/geas/src/collectiondata.c:1.24 Sun Jun 10 22:19:26 2001
+++ gnue/geas/src/collectiondata.c      Tue Jun 12 17:47:46 2001
@@ -19,7 +19,7 @@
    along with this program; if not, write to the Free Software Foundation,
    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
    
-   $Id: collectiondata.c,v 1.24 2001/06/11 05:19:26 treshna Exp $
+   $Id: collectiondata.c,v 1.25 2001/06/13 00:47:46 treshna Exp $
 
 */
 
@@ -72,10 +72,16 @@
   char *lenstr;
   ObjectData *ob;               /* object cache entry */
   unsigned long int len;
+  char *key;
+  int   fieldid;
 
   timer_start_operation( TIMER_LISTS , "Start query: find list of objects" );
+//  timer_start_profile( TIMER_FUNC_MAKELIST );
 
-  /* what class are we laoding into the list? */
+  if( using_postgresql() )
+       start_objectstore_transaction();
+
+  /* what class are we loading into the list? */
   classname = (char *) oql_query_get_classname (query);
 
   /* get list of object IDs from the object store */
@@ -89,6 +95,9 @@
         {
           free_query_result (result);
         }
+      if( using_postgresql() )
+        commit_objectstore_transaction();
+//      timer_update_profile( TIMER_FUNC_MAKELIST );
       timer_fail_operation( TIMER_LISTS );
       return (NULL);
     }
@@ -96,6 +105,10 @@
   if (!result)
     {
       self_test_message ("query failed");
+      if( using_postgresql() )
+        commit_objectstore_transaction();
+//      timer_update_profile( TIMER_FUNC_MAKELIST );
+      timer_fail_operation( TIMER_LISTS );
       return (NULL);
     }
   self_test_message ("query succeeded");
@@ -110,6 +123,9 @@
         {
           free_query_result (result);
         }
+      if( using_postgresql() )
+        commit_objectstore_transaction();
+//      timer_update_profile( TIMER_FUNC_MAKELIST );
       timer_fail_operation( TIMER_LISTS );
       return (NULL);
     }
@@ -118,6 +134,9 @@
   lst = GEAS_Connection_newObject (xid->server, "geas::listholder", ev);
   if (ev->_major != CORBA_NO_EXCEPTION)
     {
+      if( using_postgresql() )
+        commit_objectstore_transaction();
+//      timer_update_profile( TIMER_FUNC_MAKELIST );
       timer_fail_operation( TIMER_LISTS );
       return (NULL);
     }
@@ -129,6 +148,9 @@
   if (ev->_major != CORBA_NO_EXCEPTION)
     {
       printf ("E %s\n", CORBA_exception_id (ev));
+      if( using_postgresql() )
+        commit_objectstore_transaction();
+//      timer_update_profile( TIMER_FUNC_MAKELIST );
       timer_fail_operation( TIMER_LISTS );
       return (NULL);
     }
@@ -136,35 +158,51 @@
   /* create list entry objects */
   len = count_rows_in_result (result);
   debug_output (DEBUGLEVEL_3, "List length: %d", len);
-  for (i = 0; i < len; i++)
-    {
-      ObjectKey keydata;
-      /* char *tmp; */
 
-      debug_output (DEBUGLEVEL_3, "Item: %d of %d", i, len);
-      id = (char *) get_result_field (result, i /*row */ , idx /*field */ );
+  if( len > 0 ) {
+      ObjectKey keydata;
+      int fieldid = oql_query_get_field_position(query,"objectid");
+      GList *row = get_result_row(result,0);
+      i = 0;
+      while( row ) {
+          debug_output (DEBUGLEVEL_3, "Item: %d of %d", i, len); i++;
+          id = (char *) get_result_field (result, i /*row */ , idx /*field */ 
);
+
+          /* record list position object */
+          keydata = create_new_object_key ();
+          ob = oc_add_empty_object ("geas::listitem", object_key_as_string 
(keydata));
+          g_free (keydata);
+          sprintf (buf, "%d", i);
+          oc_set_object_field_quick (ob, "position" , buf, FALSE);
+          oc_set_object_field_quick (ob, "reference", id, FALSE);
+          oc_set_object_field       (ob, "listid"   , listid, FALSE);
+
+          /* make sure the object is in the cache */
+          key = get_field_in_row(row,fieldid);
+          if( oc_find_cached_object_by_key(classname,key) ) {
+            ob = oc_add_empty_object( classname , key );
+
+            for( fieldid=0 ; fieldid<result->field_count ; fieldid++ ) {
+              oc_set_object_field_quick( ob , 
get_result_field_name(result,fieldid) ,
+                                        get_field_in_row(row,fieldid) , FALSE 
);
+           }
+         }
+          row = g_list_next( row );
+      }
+  }
 
-      /* store a record of this object */
-      keydata = create_new_object_key ();
-      /* tmp = object_key_as_string (keydata); */
-      ob = oc_add_empty_object ("geas::listitem", object_key_as_string 
(keydata));
-      g_free (keydata);
-
-      /* store the object's details */
-      sprintf (buf, "%d", i);
-      oc_set_object_field (ob, "position", buf, FALSE);
-      oc_set_object_field (ob, "listid", listid, FALSE);
-      oc_set_object_field (ob, "reference", id, FALSE);
-      oc_flush_object_to_store (ob);
-    }
   lenstr = g_strdup_printf ("%lu", len);
   GEAS_DataObject_setField (lst, "length", lenstr, ev);
   g_free (lenstr);
 
   /* done, successfully */
   free_query_result (result);
-  timer_done_operation( TIMER_LISTS );
 
+  if( using_postgresql() )
+    commit_objectstore_transaction();
+
+//  timer_update_profile( TIMER_FUNC_MAKELIST );
+  timer_done_operation( TIMER_LISTS );
   return (listid);
 }
 
Index: gnue/geas/src/geas-server.c
diff -u gnue/geas/src/geas-server.c:1.102 gnue/geas/src/geas-server.c:1.103
--- gnue/geas/src/geas-server.c:1.102   Tue Jun 12 04:01:22 2001
+++ gnue/geas/src/geas-server.c Tue Jun 12 17:47:46 2001
@@ -19,7 +19,7 @@
   along with this program; if not, write to the Free Software Foundation,
   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
   
-  $Id: geas-server.c,v 1.102 2001/06/12 11:01:22 reinhard Exp $
+  $Id: geas-server.c,v 1.103 2001/06/13 00:47:46 treshna Exp $
  
 */
 
@@ -152,34 +152,77 @@
 #endif
 
 #ifdef TIMER_TESTING
-static unsigned long int timercount = 0;
 static int active_timer_sections[ TIMER_SECTIONS ];
 
-#define TIMER_us 10000
-#define TIMER_IN_SECONDS(x) ((float) (TIMER_us*(x))/1000000.0 )
+unsigned long int timer_base_seconds;
 
-void timer_handler( int arg );
-void timer_handler( int arg )
+unsigned long int timer_get_current( void );
+unsigned long int
+timer_get_current( void )
 {
-    timercount += 1;
+    struct timeval tv;
+
+    gettimeofday( &tv , NULL );
+    return ((tv.tv_sec-timer_base_seconds)*1000000)+(tv.tv_usec);
 }
+#define us_to_seconds(x)    ((float) (x)/1000000.0 )
 
 struct timer_profile
 {
-    unsigned long max,min,total,count,timercount;
+    unsigned long int max,min,total,count,timercount;
     float avg;
 };
 struct timer_profile timer_profiles[ TIMER_FUNC_COUNT ];
 
+void timer_display_profiles( void )
+{
+  int i;
+
+  printf( "\n----------------------------------\n"
+           "Profiles: (time in seconds to 4dp)\n" );
+  for( i=0 ; i<TIMER_FUNC_COUNT ; i++ ) {
+    if( timer_profiles[i].count > 0 ) {
+      printf( "PROFILE: " );
+      switch( i )
+      {
+      case TIMER_FUNC_GETFIELD   : printf( "getField()          : " ); break;
+      case TIMER_FUNC_SETFIELD   : printf( "setField()          : " ); break;
+      case TIMER_FUNC_NEWOBJECT  : printf( "newObject()         : " ); break;
+      case TIMER_FUNC_LOADALL    : printf( "loadAll()           : " ); break;
+      case TIMER_FUNC_GET_OBJECTS: printf( "_get_objects()      : " ); break;
+      case TIMER_FUNC_OPERATION  : printf( "operation           : " ); break;
+      case TIMER_FUNC_FIND_BY_KEY: printf( "find by key         : " ); break;
+      case TIMER_FUNC_FIND_CACHED_BY_KEY: printf( "find cached by key  : " ); 
break;
+      case TIMER_FUNC_GET_FIELD  : printf( "get field           : " ); break;
+      case TIMER_FUNC_SET_FIELD  : printf( "set field           : " ); break;
+      case TIMER_FUNC_FLUSH      : printf( "flush               : " ); break;
+//      case TIMER_FUNC_MAKELIST   : printf( "make list           : " ); break;
+      case TIMER_FUNC_RELEASELIST: printf( "release list        : " ); break;
+      }
+      printf( "count:%5lu min:%7.4f avg:%7.4f max:%7.4f tot:%7.4f\n" ,
+             timer_profiles[i].count,
+             us_to_seconds( timer_profiles[i].min ),
+             us_to_seconds( timer_profiles[i].avg ),
+             us_to_seconds( timer_profiles[i].max ),
+             us_to_seconds( timer_profiles[i].total ) );
+    }
+  }
+}
+
 void timer_start_profile( int function )
 {
-    timer_profiles[function].timercount = timercount;
+    timer_profiles[function].timercount = timer_get_current();
 }
 
 void timer_update_profile( int function )
 {
-  unsigned long diff;
-  diff = timercount - timer_profiles[function].timercount;
+  unsigned long int diff;
+  diff = timer_get_current() - timer_profiles[function].timercount;
+
+    if( function == TIMER_FUNC_OPERATION )
+    printf( "diff: %lu  max: %lu  min:%lu\n" , diff ,
+            timer_profiles[function].max ,
+            timer_profiles[function].min );
 
   if( timer_profiles[function].count == 0 )
   {
@@ -187,40 +230,41 @@
     timer_profiles[function].min = diff;
     timer_profiles[function].count = 1;
     timer_profiles[function].total = diff;
-    timer_profiles[function].avg = TIMER_IN_SECONDS(diff);
+    timer_profiles[function].avg = diff;
   }
   else
   {
-    if( diff > timer_profiles[function].max )
+    if( diff > timer_profiles[function].max ) {
+      if( function == TIMER_FUNC_OPERATION ) printf( "inc max\n" );
       timer_profiles[function].max = diff;
+    }
 
-    if( diff < timer_profiles[function].min )
+    if( diff < timer_profiles[function].min ) {
+      if( function == TIMER_FUNC_OPERATION ) printf( "inc max\n" );
       timer_profiles[function].min = diff;
+    }
 
     timer_profiles[function].count++;
     timer_profiles[function].total += diff;
     timer_profiles[function].avg =
-      
TIMER_IN_SECONDS(timer_profiles[function].total/timer_profiles[function].count);
+      timer_profiles[function].total/timer_profiles[function].count;
   }
-
-  #define TIMER_FUNC_GETFIELD   0
-  #define TIMER_FUNC_SETFIELD   1
-  #define TIMER_FUNC_NEWOBJECT  2
-  #define TIMER_FUNC_LOADALL    3
-
-
+/*
   printf( "PROFILE: " );
   switch( function )
    {
-   case TIMER_FUNC_GETFIELD  : printf( "getField() : " ); break;
-   case TIMER_FUNC_SETFIELD  : printf( "setField() : " ); break;
-   case TIMER_FUNC_NEWOBJECT : printf( "newObject(): " ); break;
-   case TIMER_FUNC_LOADALL   : printf( "loadAll()  : " ); break;
+   case TIMER_FUNC_GETFIELD   : printf( "getField()     : " ); break;
+   case TIMER_FUNC_SETFIELD   : printf( "setField()     : " ); break;
+   case TIMER_FUNC_NEWOBJECT  : printf( "newObject()    : " ); break;
+   case TIMER_FUNC_LOADALL    : printf( "loadAll()      : " ); break;
+   case TIMER_FUNC_GET_OBJECTS: printf( "_get_objects() : " ); break;
+   case TIMER_FUNC_OPERATION  : printf( "operation      : " ); break;
    }
-  printf( "min: %.3f avg: %.3f max: %.3f\n" ,
-         TIMER_IN_SECONDS( timer_profiles[function].min ),
-                           timer_profiles[function].avg,
-         TIMER_IN_SECONDS( timer_profiles[function].max ) );
+  printf( "min: %.6f avg: %.6f max: %.6f\n" ,
+             us_to_seconds( timer_profiles[i].max ).
+             us_to_seconds( timer_profiles[i].avg ).
+             us_to_seconds( timer_profiles[i].min ) );
+*/
 }
 
 struct timeable
@@ -242,15 +286,6 @@
   int i;
   va_list ap;
 
-  /* reset to 0 when no events are being timed */
-  /* prevents overflows for long runs, unless an */
-  /* operation takes a very long time */
-  if( timer_operation_count == (-1) ) {
-      if( active_timer_sections[section] == 1 )
-          printf( "\n" );
-      timercount = 0;
-  }
-
   /* increment stack poitner */
   timer_operation_count++;
 
@@ -262,13 +297,13 @@
   vsnprintf (timeablestack[timer_operation_count].name,128, fmt, ap);
   va_end (ap);
 
-  timeablestack[timer_operation_count].timeval = timercount;
+  timeablestack[timer_operation_count].timeval = timer_get_current();
 
   /* display start event */
   if( active_timer_sections[section] == 1 ) {
     for( i=0 ; i<timer_operation_count ; i++ )
       printf( TIMER_INDENT );
-    printf( "TIMER: START: %s (%.3f elapsed)\n" , 
timeablestack[timer_operation_count].name , TIMER_IN_SECONDS(timercount) );
+    printf( "TIMER: START: %s\n" , timeablestack[timer_operation_count].name );
   }
 }
 
@@ -279,11 +314,11 @@
   g_assert( timer_operation_count >= 0 );
 
   if( active_timer_sections[section] == 1 ) {
-    diff = timercount - timeablestack[timer_operation_count].timeval;
+    diff = timer_get_current() - timeablestack[timer_operation_count].timeval;
     for( i=0 ; i<timer_operation_count ; i++ )
       printf( TIMER_INDENT );
-    printf( "TIMER: END  : %.3f (%.3f elapsed) %s\n" ,
-           TIMER_IN_SECONDS(diff) , TIMER_IN_SECONDS(timercount) ,
+    printf( "TIMER: END  : %.6f %s\n" ,
+           us_to_seconds(diff) ,
            timeablestack[timer_operation_count].name );
   }
 
@@ -297,11 +332,11 @@
   g_assert( timer_operation_count >= 0 );
 
   if( active_timer_sections[section] == 1 ) {
-    diff = timercount - timeablestack[timer_operation_count].timeval;
+    diff = timer_get_current() - timeablestack[timer_operation_count].timeval;
     for( i=0 ; i<timer_operation_count ; i++ )
       printf( TIMER_INDENT );
-    printf( "TIMER: FAIL : %.3f (%.3f elapsed) %s\n" ,
-           TIMER_IN_SECONDS(diff) , TIMER_IN_SECONDS(timercount) ,
+    printf( "TIMER: FAIL : %.6f %s\n" ,
+           us_to_seconds(diff) ,
            timeablestack[timer_operation_count].name );
   }
 
@@ -325,6 +360,8 @@
   FILE *fp = NULL;
 #ifdef TIMER_TESTING
   struct itimerval timerdata;
+  struct timeval tv;
+  int i;
 #endif
 
   PortableServer_POA root_poa;
@@ -378,6 +415,9 @@
 #ifdef TIMER_TESTING
   /* select active sections for timing info display */
 
+  gettimeofday( &tv , NULL );
+  timer_base_seconds = tv.tv_sec;
+
   /* clear all */
   for( i=0 ; i<TIMER_SECTIONS ; i++ )
     active_timer_sections[i] = 0;
@@ -391,35 +431,10 @@
   }
 
   active_timer_sections[ TIMER_MISC     ] = 1;
-  active_timer_sections[ TIMER_SKELETON ] = 1;
+  active_timer_sections[ TIMER_SKELETON ] = 0;
   active_timer_sections[ TIMER_SKELMISC ] = 0;
   active_timer_sections[ TIMER_CACHE    ] = 0;
-  active_timer_sections[ TIMER_LISTS    ] = 1;
-
-  /* time to wait between signals */
-  timercount = 0;
-  timerdata.it_interval.tv_usec = TIMER_us;
-  timerdata.it_interval.tv_sec  = 0;
-
-  /* set initial value */
-
-#define TIMER_REAL 1
-
-  timerdata.it_value.tv_usec    = timerdata.it_interval.tv_usec;
-  timerdata.it_value.tv_sec     = timerdata.it_interval.tv_sec;
-
-#ifdef TIMER_VIRTUAL
-  setitimer( ITIMER_VIRTUAL , &timerdata , NULL ); /* raise SIGVTALRM */
-  signal( SIGVTALRM , (sighandler_t)timer_handler );
-#endif
-#ifdef TIMER_PROF
-  setitimer( ITIMER_PROF , &timerdata , NULL ); /* raise SIGPROF */
-  signal( SIGPROF , (sighandler_t)timer_handler );
-#endif
-#ifdef TIMER_REAL
-  setitimer( ITIMER_REAL , &timerdata , NULL ); /* raise SIGALRM */
-  signal( SIGALRM , (sighandler_t)timer_handler );
-#endif
+  active_timer_sections[ TIMER_LISTS    ] = 0;
 
 #endif
 
Index: gnue/geas/src/geas-server.h
diff -u gnue/geas/src/geas-server.h:1.48 gnue/geas/src/geas-server.h:1.49
--- gnue/geas/src/geas-server.h:1.48    Mon Jun 11 14:46:30 2001
+++ gnue/geas/src/geas-server.h Tue Jun 12 17:47:46 2001
@@ -20,7 +20,7 @@
    along with this program; if not, write to the Free Software Foundation,
    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
  
-   $Id: geas-server.h,v 1.48 2001/06/11 21:46:30 reinhard Exp $
+   $Id: geas-server.h,v 1.49 2001/06/13 00:47:46 treshna Exp $
 */
 
 /** \file geas-server.h
@@ -42,19 +42,31 @@
   #define TIMER_LISTS      4 /* collectiondata.c  */
   #define TIMER_SECTIONS  20 /* count of sections */
 
-  #define TIMER_FUNC_GETFIELD   0
-  #define TIMER_FUNC_SETFIELD   1
-  #define TIMER_FUNC_NEWOBJECT  2
-  #define TIMER_FUNC_LOADALL    3
+  #define TIMER_FUNC_GETFIELD      0
+  #define TIMER_FUNC_SETFIELD      1
+  #define TIMER_FUNC_NEWOBJECT     2
+  #define TIMER_FUNC_LOADALL       3
+  #define TIMER_FUNC_GET_OBJECTS   4
+
+  #define TIMER_FUNC_FIND_BY_KEY   6
+  #define TIMER_FUNC_FIND_CACHED_BY_KEY  7
+  #define TIMER_FUNC_GET_FIELD     8
+  #define TIMER_FUNC_SET_FIELD     9
+  #define TIMER_FUNC_FLUSH        10
+  #define TIMER_FUNC_MAKELIST     11
+  #define TIMER_FUNC_RELEASELIST  12
 
-  #define TIMER_FUNC_COUNT     50
+  #define TIMER_FUNC_OPERATION    49
 
+  #define TIMER_FUNC_COUNT       100
 
+
   void timer_start_operation ( int section , char *name , ... );
   void timer_done_operation  ( int section );
   void timer_fail_operation  ( int section );
   void timer_start_profile   ( int function );
   void timer_update_profile  ( int function );
+  void timer_display_profiles( void );
 
 #else
   #define timer_start_operation(x,dummy,...) /* empty */
@@ -63,6 +75,7 @@
 
   #define timer_start_profile(dummy)         /* empty */
   #define timer_update_profile(dummy)        /* empty */
+  #define timer_display_profiles()           /* empty */
 #endif
 
 /** \brief username reserved for the server */
Index: gnue/geas/src/geas-skeleton.c
diff -u gnue/geas/src/geas-skeleton.c:1.63 gnue/geas/src/geas-skeleton.c:1.64
--- gnue/geas/src/geas-skeleton.c:1.63  Sun Jun 10 22:19:26 2001
+++ gnue/geas/src/geas-skeleton.c       Tue Jun 12 17:47:46 2001
@@ -19,7 +19,7 @@
    along with this program; if not, write to the Free Software Foundation,
    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
    
-   $Id: geas-skeleton.c,v 1.63 2001/06/11 05:19:26 treshna Exp $
+   $Id: geas-skeleton.c,v 1.64 2001/06/13 00:47:46 treshna Exp $
  
 */
 
@@ -1058,6 +1058,28 @@
   GEAS_ObjectList retval = CORBA_OBJECT_NIL;
   GEAS_object_reference *id;
 
+#ifdef TIMER_TESTING
+  /* yet another quick hack - isn't this fun? */
+  if( strcmp(classname,"averages") == 0 )
+   {
+     timer_display_profiles();
+     make_ServerError_exception(ev,"not really an error");
+     return retval;
+   }
+  if( strcmp(classname,"start") == 0 )
+   {
+     timer_start_profile(TIMER_FUNC_OPERATION);
+     make_ServerError_exception(ev,"not really an error");
+     return retval;
+   }
+  if( strcmp(classname,"done") == 0 )
+   {
+     timer_update_profile(TIMER_FUNC_OPERATION);
+     make_ServerError_exception(ev,"not really an error");
+     return retval;
+   }
+#endif
+
   timer_start_operation(TIMER_SKELETON,"loadAll(%s)",classname);
   timer_start_profile( TIMER_FUNC_LOADALL );
   trace_functioncall ();
@@ -1944,6 +1966,7 @@
   GEAS_object_reference *id;
 
   timer_start_operation(TIMER_SKELETON,__PRETTY_FUNCTION__);
+  timer_start_profile( TIMER_FUNC_GET_OBJECTS );
   trace_functioncall ();
 
   if (allow_oid_refill)
@@ -1958,6 +1981,7 @@
   retval = ObjectList__get_objects (id, ev);
 
   free_geas_object_reference (id);
+  timer_update_profile( TIMER_FUNC_GET_OBJECTS );
   timer_done_operation( TIMER_SKELETON );
   return retval;
 }
Index: gnue/geas/src/objectcache/objectcache.c
diff -u gnue/geas/src/objectcache/objectcache.c:1.52 
gnue/geas/src/objectcache/objectcache.c:1.53
--- gnue/geas/src/objectcache/objectcache.c:1.52        Tue Jun 12 04:17:24 2001
+++ gnue/geas/src/objectcache/objectcache.c     Tue Jun 12 17:47:46 2001
@@ -19,7 +19,7 @@
    along with this program; if not, write to the Free Software Foundation,
    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
    
-   $Id: objectcache.c,v 1.52 2001/06/12 11:17:24 reinhard Exp $
+   $Id: objectcache.c,v 1.53 2001/06/13 00:47:46 treshna Exp $
 */
 
 #include "config.h"
@@ -253,14 +253,16 @@
   ObjectData *obj;
   QueryData *q;
 
-  timer_start_operation( TIMER_CACHE , __PRETTY_FUNCTION__ );
+
   trace_functioncall ();
   obj = oc_find_cached_object_by_key (classname, key);
   if (obj)
     {
-      timer_fail_operation( TIMER_CACHE);
       return (obj);
     }
+  timer_start_operation( TIMER_CACHE , __PRETTY_FUNCTION__ );
+  timer_start_profile( TIMER_FUNC_FIND_BY_KEY );
+
   /* not in cache, so load from database */
   q = oql_load_object_by_key (classname, key);
   if (q)
@@ -268,6 +270,7 @@
       obj = oc_objectstore_query_to_objectcache (q);
     }
   oql_free_query (q);
+  timer_update_profile( TIMER_FUNC_FIND_BY_KEY );
   timer_done_operation( TIMER_CACHE );
   return (obj);
 }
@@ -283,6 +286,7 @@
   char *p;
 
   timer_start_operation( TIMER_CACHE , __PRETTY_FUNCTION__ );
+  timer_start_profile( TIMER_FUNC_FIND_CACHED_BY_KEY );
   trace_functioncall ();
   if (strncmp (classname, "root::", 6) == 0)
     {
@@ -297,6 +301,7 @@
   lookup = g_strdup_printf ("%s-%s", p, key);
   obj = g_hash_table_lookup (cachedata, lookup);
   g_free (lookup);
+  timer_update_profile( TIMER_FUNC_FIND_CACHED_BY_KEY );
   timer_done_operation( TIMER_CACHE );
   return (obj);
 }
@@ -315,14 +320,16 @@
   char *oid = g_strdup (key);
   char *p;
 
+  /* printf( "adding object: currently %d entries in cache\n" , 
objectcache_count ); */
+
   timer_start_operation( TIMER_CACHE , __PRETTY_FUNCTION__ );
   trace_functioncall ();
 
   /* if there's still any '-' characters, remove them */
-  if (strchr (key, '-') != NULL)
-    {
-      cleanup_oid (oid);
-    }
+//  if (strchr (key, '-') != NULL)
+//    {
+//      cleanup_oid (oid);
+//    }
 
   if (strncmp (classname, "root::", 6) == 0)
     {
@@ -478,7 +485,7 @@
   if (oc_find_object_by_key (classname, keystr))
     return (TRUE);
   else
-    return (FALSE);
+    return FALSE;
 }
 
 /* ------------------------------------------------------------------------- *\
@@ -497,6 +504,7 @@
   GHashTable *values;
 
   timer_start_operation( TIMER_CACHE , __PRETTY_FUNCTION__ );
+  timer_start_profile( TIMER_FUNC_FLUSH );
   trace_functioncall ();
   /* TODO: error checking, updating object flags */
 
@@ -521,6 +529,7 @@
       printf ("TODO: error handler at %s/%d\n", __FILE__, __LINE__);
       exit (0);
     }
+  timer_update_profile( TIMER_FUNC_FLUSH );
   timer_done_operation( TIMER_CACHE );
 }
 
@@ -582,12 +591,14 @@
   /* ObjectData *o = NULL; */
 
   trace_functioncall ();
+  timer_start_profile( TIMER_FUNC_GET_FIELD );
 
   flushable = oc_object_to_start_of_list (flushable, object);
 
   /* special case */
   if (g_strcasecmp ("objectid", fieldname) == 0)
     {
+      timer_update_profile( TIMER_FUNC_GET_FIELD );
       return (g_strdup (object->key));
     }
   /* look for field name in object */
@@ -595,15 +606,20 @@
   if (f)
     {
       /* found in cache, returnm it */
+      timer_update_profile( TIMER_FUNC_GET_FIELD );
       return (g_strdup (f->value));
     }
   /* get class and field info */
   cl = odl_find_class (all_classes, object->classname, NULL);
-  if (!cl)
+  if (!cl) {
+    timer_update_profile( TIMER_FUNC_GET_FIELD );
     return (NULL);
+  }
   ft = odl_class_get_field (cl, fieldname);
-  if (!ft)
+  if (!ft) {
+    timer_update_profile( TIMER_FUNC_GET_FIELD );
     return (NULL);
+  }
   switch (odl_field_get_type (ft))
     {
     case FT_basic:
@@ -620,9 +636,11 @@
               if (f)
                 {
                   /* found in cache, returnm it */
+                 timer_update_profile( TIMER_FUNC_GET_FIELD );
                   return (g_strdup (f->value));
                 }
               /* still not found? damn.. */
+             timer_update_profile( TIMER_FUNC_GET_FIELD );
               return (NULL);
             }
         }
@@ -644,6 +662,7 @@
         q = create_base_query (loadclass);
         if (!q)
           {
+           timer_update_profile( TIMER_FUNC_GET_FIELD );
             return (NULL);
           }
         /* add constraints to find just members of this lookup */
@@ -657,6 +676,7 @@
             if (!c)
               {
                 oql_free_query (q);
+               timer_update_profile( TIMER_FUNC_GET_FIELD );
                 return (NULL);
               }
             o =
@@ -665,6 +685,7 @@
             if (!o)
               {
                 oql_free_query (q);
+               timer_update_profile( TIMER_FUNC_GET_FIELD );
                 return (NULL);
               }
             value = (char *) oc_get_object_field (o, t->data);
@@ -673,6 +694,7 @@
                  (const char *) s->data))
               {
                 oql_free_query (q);
+               timer_update_profile( TIMER_FUNC_GET_FIELD );
                 return (NULL);
               }
             s = g_list_next (s);
@@ -684,6 +706,7 @@
             criticalerror ("%s.%s has unbalanced field lists",
                            odl_class_get_full_name (cl), fieldname);
             oql_free_query (q);
+           timer_update_profile( TIMER_FUNC_GET_FIELD );
             return (NULL);
           }
         if (q)
@@ -702,6 +725,7 @@
                   {
                     f->readonly = TRUE;
                   }
+               timer_update_profile( TIMER_FUNC_GET_FIELD );
                 return (retval);
               }
           }
@@ -713,6 +737,7 @@
     }
 
   /* didn't find it */
+  timer_update_profile( TIMER_FUNC_GET_FIELD );
   return (NULL);
 }
 
@@ -720,6 +745,43 @@
  * Set the data of a field of the object
 \* ------------------------------------------------------------------------- */
 gboolean
+oc_set_object_field_quick (ObjectData * object, const char *fieldname,
+                     const char *value, gboolean readonly)
+{
+  _FieldData *f;
+  GList *idxs, *l, *ids;
+  odl_class *c;
+
+  timer_start_profile( TIMER_FUNC_SET_FIELD );
+
+  if (g_strcasecmp ("objectid", fieldname) == 0)
+    {
+      timer_update_profile( TIMER_FUNC_SET_FIELD );
+      return (FALSE);
+    }
+  f = g_hash_table_lookup (object->fields, fieldname);
+  if (!f)
+    {
+      f = oc_alloc_field_data (fieldname);
+      if (f)
+        {
+          g_hash_table_insert (object->fields, f->name, f);
+        }
+    }
+  if (f)
+    {
+      if (f->value)
+        {
+          g_free (f->value);
+        }
+      f->value = g_strdup (value);
+    }
+
+  timer_update_profile( TIMER_FUNC_SET_FIELD );
+  return FALSE;
+}
+
+gboolean
 oc_set_object_field (ObjectData * object, const char *fieldname,
                      const char *value, gboolean readonly)
 {
@@ -728,8 +790,10 @@
   odl_class *c;
 
   trace_functioncall ();
+  timer_start_profile( TIMER_FUNC_SET_FIELD );
   if (g_strcasecmp ("objectid", fieldname) == 0)
     {
+      timer_update_profile( TIMER_FUNC_SET_FIELD );
       return (FALSE);
     }
   f = g_hash_table_lookup (object->fields, fieldname);
@@ -750,6 +814,7 @@
       /* a readonly field can be set the first time */
       if (f->readonly)
         {
+         timer_update_profile( TIMER_FUNC_SET_FIELD );
           return (FALSE);
         }
       if (readonly)
@@ -828,8 +893,10 @@
           oc_free_index_identifier_list (ids);
         }
       flushable = oc_object_to_start_of_list (flushable, object);
+      timer_update_profile( TIMER_FUNC_SET_FIELD );
       return (TRUE);
     }
+  timer_update_profile( TIMER_FUNC_SET_FIELD );
   return (FALSE);
 }
 
Index: gnue/geas/src/objectcache/objectcache.h
diff -u gnue/geas/src/objectcache/objectcache.h:1.17 
gnue/geas/src/objectcache/objectcache.h:1.18
--- gnue/geas/src/objectcache/objectcache.h:1.17        Sun Jun 10 06:12:35 2001
+++ gnue/geas/src/objectcache/objectcache.h     Tue Jun 12 17:47:46 2001
@@ -20,7 +20,7 @@
    along with this program; if not, write to the Free Software Foundation,
    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
    
-   $Id: objectcache.h,v 1.17 2001/06/10 13:12:35 ntiffin Exp $
+   $Id: objectcache.h,v 1.18 2001/06/13 00:47:46 treshna Exp $
  
 */
 
@@ -78,6 +78,10 @@
 /* Data access */
 char *oc_get_object_field (ObjectData * object, const char *fieldname);
 gboolean oc_set_object_field (ObjectData * object, const char *fieldname,
+                              const char *value, gboolean readonly);
+
+/* only call this if the field is not part of an index */
+gboolean oc_set_object_field_quick(ObjectData * object, const char *fieldname,
                               const char *value, gboolean readonly);
 
 ObjectData *oc_search_for_single_object (_QueryData * q);
Index: gnue/geas/src/objectlist.c
diff -u gnue/geas/src/objectlist.c:1.24 gnue/geas/src/objectlist.c:1.25
--- gnue/geas/src/objectlist.c:1.24     Sat Jun  9 08:27:02 2001
+++ gnue/geas/src/objectlist.c  Tue Jun 12 17:47:46 2001
@@ -20,7 +20,7 @@
    along with this program; if not, write to the Free Software Foundation,
    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
    
-   $Id: objectlist.c,v 1.24 2001/06/09 15:27:02 ntiffin Exp $
+   $Id: objectlist.c,v 1.25 2001/06/13 00:47:46 treshna Exp $
  
 */
 
@@ -521,9 +521,31 @@
 void
 ObjectList_release (GEAS_object_reference * id, CORBA_Environment * ev)
 {
+  char *len;
+  CORBA_unsigned_long retval = 0;
+  ObjectData *ob;
+  int length,i;
+
   /* QueryData *q; */
   struct query_result *result;
 
+  timer_start_profile( TIMER_FUNC_RELEASELIST );
+
+  ob = oc_find_object_by_key ("geas::listholder", id->listid);
+  if (!ob)
+    {
+      make_ServerError_exception( ev , "list data lost" );
+      timer_update_profile( TIMER_FUNC_RELEASELIST );
+      return;
+    }
+  len = oc_get_object_field (ob, "length");
+  length = atoi (len);
+  g_free (len);
+  oc_delete_object( "geas::listholder" , id->listid );
+
+//  for( i=0 ; i<length ; i++ )
+//    oc_delete_objectfrom_cache( "geas::listitem" , id->listid );
+
   /* delete the geas::listholder object */
   result =
     delete_from_objectstore ("geas::listholder", id->listid, NULL, NULL);
@@ -539,4 +561,5 @@
     {
       free_query_result (result);
     }
+  timer_update_profile( TIMER_FUNC_RELEASELIST );
 }
Index: gnue/geas/src/objectstore/objectstore.c
diff -u gnue/geas/src/objectstore/objectstore.c:1.66 
gnue/geas/src/objectstore/objectstore.c:1.67
--- gnue/geas/src/objectstore/objectstore.c:1.66        Sun Jun 10 06:12:35 2001
+++ gnue/geas/src/objectstore/objectstore.c     Tue Jun 12 17:47:47 2001
@@ -19,7 +19,7 @@
    along with GEAS; if not, write to the Free Software Foundation, Inc.,
    59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-   $Id: objectstore.c,v 1.66 2001/06/10 13:12:35 ntiffin Exp $
+   $Id: objectstore.c,v 1.67 2001/06/13 00:47:47 treshna Exp $
    
 */
 
@@ -436,6 +436,44 @@
     g_list_free (database_list);
   database_list = NULL;
   return (TRUE);
+}
+
+int using_postgresql( void )
+{
+  struct database_handle *h = NULL;
+
+  const char *database = get_first_active_database(configdata); /* HACK */
+  h = find_database_handle (database_list, database, NULL,NULL);
+
+  if( g_strcasecmp(h->type,"postgresql") == 0 ) return 1;
+  return 0;
+}
+
+
+/* hack!   another hack!  */
+void start_objectstore_transaction( void )
+{
+  struct database_handle *h = NULL;
+  const char *database = get_first_active_database(configdata); /* HACK */
+
+  h = find_database_handle (database_list, database, NULL,NULL);
+  if (!h)
+    return;
+
+  h->begintransaction (h);
+}
+
+/* and some more of the hack! */
+void commit_objectstore_transaction( void )
+{
+  struct database_handle *h = NULL;
+  const char *database = get_first_active_database(configdata); /* HACK */
+
+  h = find_database_handle (database_list, database, NULL,NULL);
+  if (!h)
+    return;
+
+  h->committransaction (h);
 }
 
 /* ========================================================================= *\
Index: gnue/geas/src/objectstore/objectstore.h
diff -u gnue/geas/src/objectstore/objectstore.h:1.21 
gnue/geas/src/objectstore/objectstore.h:1.22
--- gnue/geas/src/objectstore/objectstore.h:1.21        Wed Jun  6 16:45:33 2001
+++ gnue/geas/src/objectstore/objectstore.h     Tue Jun 12 17:47:47 2001
@@ -20,7 +20,7 @@
    along with GEAS; if not, write to the Free Software Foundation, Inc.,
    59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-   $Id: objectstore.h,v 1.21 2001/06/06 23:45:33 ntiffin Exp $
+   $Id: objectstore.h,v 1.22 2001/06/13 00:47:47 treshna Exp $
 */
 
 #ifndef _OBJECTSTORE_H
@@ -125,5 +125,16 @@
  * the appropriate tables.
  */
 void                  update_objectstore_databases (gboolean remove_items);
+
+/* start another hack... noone wants to waste time thinking about    */
+/* the future effects of code - it's much more fun to solev problems */
+/* when they happen, rather than avoid causing problems              */
+/* btw, they're postgresql only features - will die if you're using mysql */
+void start_objectstore_transaction( void );
+
+/* and the rest of it */
+void commit_objectstore_transaction( void );
+
+int using_postgresql( void );
 
 #endif /* not _OBJECTSTORE_H */
Index: gnue/geas/src/objectstore/objectstore_private.h
diff -u gnue/geas/src/objectstore/objectstore_private.h:1.1 
gnue/geas/src/objectstore/objectstore_private.h:1.2
--- gnue/geas/src/objectstore/objectstore_private.h:1.1 Wed Jun  6 09:01:23 2001
+++ gnue/geas/src/objectstore/objectstore_private.h     Tue Jun 12 17:47:47 2001
@@ -20,7 +20,7 @@
    along with GEAS; if not, write to the Free Software Foundation, Inc.,
    59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-   $Id: objectstore_private.h,v 1.1 2001/06/06 16:01:23 ntiffin Exp $
+   $Id: objectstore_private.h,v 1.2 2001/06/13 00:47:47 treshna Exp $
 */
 
 #ifndef _OBJECTSTORE_PRIVATE_H
@@ -84,6 +84,9 @@
                                          const char *database,
                                          struct database_handle *h);
 
+typedef void (*hack_function) (struct database_handle * ph);
+
+
 struct active_connection
 {
   /* general data */
@@ -121,6 +124,9 @@
   delete_all_objects_function delete_all_objects;
   write_object_function write_object;
   update_tables_function update_tables;
+
+  hack_function begintransaction;
+  hack_function committransaction;
 };
 
 void free_generic_database (struct database_handle *h);
@@ -155,4 +161,4 @@
 MySQL_create_database_handle (configuration config, const char *dbname);
 
 
-#endif /* _OBJECTSTORE_PRIVATE_H */
\ No newline at end of file
+#endif /* _OBJECTSTORE_PRIVATE_H */
Index: gnue/geas/src/objectstore/postgresql.c
diff -u gnue/geas/src/objectstore/postgresql.c:1.4 
gnue/geas/src/objectstore/postgresql.c:1.5
--- gnue/geas/src/objectstore/postgresql.c:1.4  Fri Jun  8 22:58:40 2001
+++ gnue/geas/src/objectstore/postgresql.c      Tue Jun 12 17:47:47 2001
@@ -20,7 +20,7 @@
    along with GEAS; if not, write to the Free Software Foundation, Inc.,
    59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
-   $Id: postgresql.c,v 1.4 2001/06/09 05:58:40 baumannd Exp $
+   $Id: postgresql.c,v 1.5 2001/06/13 00:47:47 treshna Exp $
 */
 
 #include "config.h"
@@ -75,6 +75,32 @@
 \* ========================================================================= */
 
 /* ------------------------------------------------------------------------- *\
+ * A hack (begin transaction) - supposed to improve database speed, no other
+ * effect
+\* ------------------------------------------------------------------------- */
+void postgresql_hack_begin(struct database_handle *ph);
+void postgresql_hack_begin(struct database_handle *ph)
+{
+  struct postgresql_connection *conn;
+  conn = (struct postgresql_connection *) ph->get_connection (ph);
+  PQexec (conn->handle, "BEGIN TRANSACTION" );
+  conn->base.available = TRUE;
+}
+
+/* ------------------------------------------------------------------------- *\
+ * A hack (commit transaction) - supposed to improve database speed, no other
+ * effect
+\* ------------------------------------------------------------------------- */
+void postgresql_hack_commit(struct database_handle *ph);
+void postgresql_hack_commit(struct database_handle *ph)
+{
+  struct postgresql_connection *conn;
+  conn = (struct postgresql_connection *) ph->get_connection (ph);
+  PQexec (conn->handle, "COMMIT TRANSACTION" );
+  conn->base.available = TRUE;
+}
+
+/* ------------------------------------------------------------------------- *\
  * handle postgresql produced NOTICE messages
 \* ------------------------------------------------------------------------- */
 void
@@ -960,6 +986,8 @@
       h->delete_all_objects = postgresql_delete_all_objects;
       h->write_object = postgresql_write_object;
       h->update_tables = postgresql_update_tables;
+      h->begintransaction = postgresql_hack_begin;
+      h->committransaction = postgresql_hack_commit;
 
       /* create connection data storage */
       h->connections =



reply via email to

[Prev in Thread] Current Thread [Next in Thread]