F #2489: Improve performance of oned:

* Reduce memory footprint
    * Improve connection handling in the RequestManager
    * Reduce the number of locking calls
    * Reduce the size of the VM pool
This commit is contained in:
Ruben S. Montero committed 2018-10-09 11:15:59 +02:00
1 parent a69baeee1a
commit f54e066949
90 files changed
+1573 -659

No files matched your search

+63 -20
View File
@@ -123,8 +123,6 @@ int PoolSQL::allocate(PoolObjectSQL *objsql, string& error_str)
lastOID = -1;
}
objsql->lock();
objsql->oid = ++lastOID;
if ( _set_lastOID(lastOID, db, table) == -1 )
@@ -168,28 +166,52 @@ PoolObjectSQL * PoolSQL::get(int oid)
return 0;
}
PoolObjectSQL * objectsql;
pthread_mutex_t * object_lock = cache.lock_line(oid);
cache.lock_line(oid);
objectsql = create();
PoolObjectSQL * objectsql = create();
objectsql->oid = oid;
objectsql->ro = false;
objectsql->mutex = object_lock;
int rc = objectsql->select(db);
if ( rc != 0 )
{
delete objectsql;
cache.set_line(oid, 0);
objectsql->unlock(); //Free object and unlock cache line mutex
return 0;
}
objectsql->lock();
return objectsql;
}
cache.set_line(oid, objectsql);
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
PoolObjectSQL * PoolSQL::get_ro(int oid)
{
if ( oid < 0 )
{
return 0;
}
PoolObjectSQL * objectsql = create();
objectsql->oid = oid;
objectsql->ro = true;
int rc = objectsql->select(db);
if ( rc != 0 )
{
objectsql->unlock(); //Free object;
return 0;
}
return objectsql;
}
@@ -213,12 +235,27 @@ PoolObjectSQL * PoolSQL::get(const string& name, int ouid)
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int PoolSQL::dump(ostringstream& oss, const string& elem_name, const char* table,
PoolObjectSQL * PoolSQL::get_ro(const string& name, int uid)
{
int oid = PoolObjectSQL::select_oid(db, table.c_str(), name, uid);
if ( oid == -1 )
{
return 0;
}
return get_ro(oid);
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int PoolSQL::dump(string& oss, const string& elem_name, const string& column, const char* table,
const string& where, const string& limit, bool desc)
{
ostringstream cmd;
cmd << "SELECT body FROM " << table;
cmd << "SELECT " << column << " FROM " << table;
if ( !where.empty() )
{
@@ -243,25 +280,31 @@ int PoolSQL::dump(ostringstream& oss, const string& elem_name, const char* table
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int PoolSQL::dump(ostringstream& oss, const string& root_elem_name,
int PoolSQL::dump(string& oss, const string& root_elem_name,
ostringstream& sql_query)
{
int rc;
stream_cb cb(1);
string_cb cb(1);
oss << "<" << root_elem_name << ">";
ostringstream oelem;
oelem << "<" << root_elem_name << ">";
oss.append(oelem.str());
cb.set_callback(&oss);
rc = db->exec_rd(sql_query, &cb);
add_extra_xml(oss);
oss << "</" << root_elem_name << ">";
cb.unset_callback();
oelem.str("");
oelem << "</" << root_elem_name << ">";
oss.append(oelem.str());
return rc;
}