The branch, master has been updated
       via  9a02f61547ddf74629aca21639d8fb61c1df7cbb (commit)
      from  d05faf294e58e22ae3fbc76162258f1ae8178129 (commit)

http://gitweb.samba.org/?p=ctdb.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 9a02f61547ddf74629aca21639d8fb61c1df7cbb
Author: Volker Lendecke <v...@samba.org>
Date:   Thu Nov 22 15:27:51 2012 +0100

    vacuum: Avoid some tallocs in ctdb recovery
    
    In a heavily loaded and volatile database a lot of SCHEDULE_FOR_DELETION
    requests can come in between fast vacuuming runs. This can lead to
    significant ctdb cpu load due to the cost of doing talloc_free. This
    reduces the number of objects a bit by coalescing the two objects
    of delete_record_data into one. It will also avoid having to allocate
    another talloc header for a SCHEDULE_FOR_DELETION key. Not the full fix
    for this problem, but it might contribute a bit.

-----------------------------------------------------------------------

Summary of changes:
 server/ctdb_vacuum.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)


Changeset truncated at 500 lines:

diff --git a/server/ctdb_vacuum.c b/server/ctdb_vacuum.c
index 7f6a8f5..4a000b0 100644
--- a/server/ctdb_vacuum.c
+++ b/server/ctdb_vacuum.c
@@ -91,6 +91,7 @@ struct delete_record_data {
        struct ctdb_db_context *ctdb_db;
        struct ctdb_ltdb_header hdr;
        TDB_DATA key;
+       uint8_t keydata[1];
 };
 
 struct delete_records_list {
@@ -108,21 +109,22 @@ static int insert_delete_record_data_into_tree(struct 
ctdb_context *ctdb,
 {
        struct delete_record_data *dd;
        uint32_t hash;
+       size_t len;
 
-       dd = talloc_zero(tree, struct delete_record_data);
+       len = offsetof(struct delete_record_data, keydata) + key.dsize;
+
+       dd = (struct delete_record_data *)talloc_size(tree, len);
        if (dd == NULL) {
                DEBUG(DEBUG_ERR,(__location__ " Out of memory\n"));
                return -1;
        }
+       talloc_set_name_const(dd, "struct delete_record_data");
 
        dd->ctdb      = ctdb;
        dd->ctdb_db   = ctdb_db;
        dd->key.dsize = key.dsize;
-       dd->key.dptr  = talloc_memdup(dd, key.dptr, key.dsize);
-       if (dd->key.dptr == NULL) {
-               DEBUG(DEBUG_ERR,(__location__ " Out of memory\n"));
-               return -1;
-       }
+       dd->key.dptr  = dd->keydata;
+       memcpy(dd->keydata, key.dptr, key.dsize);
 
        dd->hdr = *hdr;
 


-- 
CTDB repository

Reply via email to