MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:dlenev Date:November 1 2006 12:26pm
Subject:bk commit into 5.0 tree (dlenev:1.2292)
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of dlenev. When dlenev does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2006-11-01 15:26:04+03:00, dlenev@stripped +4 -0
  Small cleanup in code handling stored routines/table prelocking.
  
  Use lazy initialization for Query_tables_list::sroutines hash.
  This step should significantly decrease amount of memory consumed
  by stored routines as we no longer will allocate chunk of memory
  required for this HASH for each statement in routine.

  include/hash.h@stripped, 2006-11-01 15:26:02+03:00, dlenev@stripped +2 -0
    Introduced auxillary hash_init_opt() macro which simplifies
    lazy initialization of HASH objects.

  sql/sp.cc@stripped, 2006-11-01 15:26:02+03:00, dlenev@stripped +4 -0
    Use lazy initialization for Query_tables_list::sroutines hash.
    This step should significantly decrease amount of memory consumed
    by stored routines as we no longer will allocate chunk of memory
    required for this HASH for each statement in routine.

  sql/sql_lex.cc@stripped, 2006-11-01 15:26:02+03:00, dlenev@stripped +10 -1
    Use lazy initialization for Query_tables_list::sroutines hash.
    This step should significantly decrease amount of memory consumed
    by stored routines as we no longer will allocate chunk of memory
    required for this HASH for each statement in routine.

  sql/sql_lex.h@stripped, 2006-11-01 15:26:02+03:00, dlenev@stripped +5 -1
    Updated comment describing Query_tables_list::sroutines to
    reflect that now we are use lazy initialization for this hash.
    Added constant for initial size of this hash.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	dlenev
# Host:	mockturtle.local
# Root:	/home/dlenev/src/mysql-5.0-hash-2

--- 1.17/include/hash.h	2006-11-01 15:26:09 +03:00
+++ 1.18/include/hash.h	2006-11-01 15:26:09 +03:00
@@ -65,6 +65,8 @@
 
 #define hash_clear(H) bzero((char*) (H),sizeof(*(H)))
 #define hash_inited(H) ((H)->array.buffer != 0)
+#define hash_init_opt(A,B,C,D,E,F,G,H) \
+          (!hash_inited(A) && _hash_init(A,B,C,D,E,F,G, H CALLER_INFO))
 
 #ifdef	__cplusplus
 }

--- 1.202/sql/sql_lex.cc	2006-11-01 15:26:09 +03:00
+++ 1.203/sql/sql_lex.cc	2006-11-01 15:26:09 +03:00
@@ -1634,9 +1634,18 @@
   query_tables_last= &query_tables;
   query_tables_own_last= 0;
   if (init)
-    hash_init(&sroutines, system_charset_info, 0, 0, 0, sp_sroutine_key, 0, 0);
+  {
+    /*
+      We delay real initialization of hash (and therefore related
+      memory allocation) until first insertion into this hash.
+    */
+    hash_clear(&sroutines);
+  }
   else if (sroutines.records)
+  {
+    // Non-zero sroutines.records means that hash was initialized.
     my_hash_reset(&sroutines);
+  }
   sroutines_list.empty();
   sroutines_list_own_last= sroutines_list.next;
   sroutines_list_own_elements= 0;

--- 1.229/sql/sql_lex.h	2006-11-01 15:26:09 +03:00
+++ 1.230/sql/sql_lex.h	2006-11-01 15:26:09 +03:00
@@ -742,7 +742,11 @@
     0 - indicates that this query does not need prelocking.
   */
   TABLE_LIST **query_tables_own_last;
-  /* Set of stored routines called by statement. */
+  /*
+    Set of stored routines called by statement.
+    (Note that we use lazy-initialization for this hash).
+  */
+  enum { START_SROUTINES_HASH_SIZE= 16 };
   HASH sroutines;
   /*
     List linking elements of 'sroutines' set. Allows you to add new elements

--- 1.120/sql/sp.cc	2006-11-01 15:26:09 +03:00
+++ 1.121/sql/sp.cc	2006-11-01 15:26:09 +03:00
@@ -1369,6 +1369,10 @@
                              const LEX_STRING *key,
                              TABLE_LIST *belong_to_view)
 {
+  hash_init_opt(&lex->sroutines, system_charset_info,
+                Query_tables_list::START_SROUTINES_HASH_SIZE,
+                0, 0, sp_sroutine_key, 0, 0);
+
   if (!hash_search(&lex->sroutines, (byte *)key->str, key->length))
   {
     Sroutine_hash_entry *rn=
Thread
bk commit into 5.0 tree (dlenev:1.2292)dlenev1 Nov