db-campaign: Do only load completed pilots from variant
Since we know for which variant we want to have the completed pilots, we do not have to catch all pilot_ids but only those who of pilots that are finished and have the correct variant_id. This speeds the startup of the campaign server enormously when having many completed campaigns in the database. Change-Id: I8be584a2dd6d8d7315f30dcb5bff89647353001e
This commit is contained in:
@ -79,11 +79,14 @@ bool DatabaseCampaign::run() {
|
|||||||
boost::thread collect_thread(&DatabaseCampaign::collect_result_thread, this);
|
boost::thread collect_thread(&DatabaseCampaign::collect_result_thread, this);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
load_completed_pilots();
|
|
||||||
|
|
||||||
std::vector<Database::Variant> variants = db->get_variants(variant, benchmark);
|
std::vector<Database::Variant> variants = db->get_variants(variant, benchmark);
|
||||||
for (std::vector<Database::Variant>::const_iterator it = variants.begin();
|
for (std::vector<Database::Variant>::const_iterator it = variants.begin();
|
||||||
it != variants.end(); ++it) {
|
it != variants.end(); ++it) {
|
||||||
|
// Which Pilots were already processed?
|
||||||
|
load_completed_pilots(*it);
|
||||||
|
|
||||||
|
// Push all other variants to the queue
|
||||||
if (!run_variant(*it)) {
|
if (!run_variant(*it)) {
|
||||||
log_send << "run_variant failed for " << it->variant << "/" << it->benchmark <<std::endl;
|
log_send << "run_variant failed for " << it->variant << "/" << it->benchmark <<std::endl;
|
||||||
return false;
|
return false;
|
||||||
@ -216,14 +219,17 @@ bool DatabaseCampaign::run_variant(Database::Variant variant) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DatabaseCampaign::load_completed_pilots()
|
void DatabaseCampaign::load_completed_pilots(Database::Variant variant)
|
||||||
{
|
{
|
||||||
// load list of partially or completely finished pilots
|
// load list of partially or completely finished pilots
|
||||||
|
log_send << "loading completed pilot IDs ... (" << variant.variant << "/"
|
||||||
|
<< variant.benchmark << ")" << std::endl;
|
||||||
std::stringstream sql;
|
std::stringstream sql;
|
||||||
sql << "SELECT pilot_id, COUNT(*) FROM " << db_connect.result_table()
|
sql << "SELECT pilot_id, COUNT(*) FROM fsppilot p"
|
||||||
|
<< " JOIN " << db_connect.result_table() << " r ON r.pilot_id = p.id"
|
||||||
|
<< " WHERE variant_id = " << variant.id
|
||||||
<< " GROUP BY pilot_id ";
|
<< " GROUP BY pilot_id ";
|
||||||
MYSQL_RES *ids = db->query_stream(sql.str().c_str());
|
MYSQL_RES *ids = db->query_stream(sql.str().c_str());
|
||||||
log_send << "loading completed pilot IDs ..." << std::endl;
|
|
||||||
MYSQL_ROW row;
|
MYSQL_ROW row;
|
||||||
unsigned rowcount = 0;
|
unsigned rowcount = 0;
|
||||||
while ((row = mysql_fetch_row(ids)) != 0) {
|
while ((row = mysql_fetch_row(ids)) != 0) {
|
||||||
|
|||||||
@ -29,7 +29,7 @@ class DatabaseCampaign : public Campaign {
|
|||||||
int fspmethod_id; // !< Which fspmethod should be put out to the clients
|
int fspmethod_id; // !< Which fspmethod should be put out to the clients
|
||||||
|
|
||||||
void collect_result_thread();
|
void collect_result_thread();
|
||||||
void load_completed_pilots();
|
void load_completed_pilots(fail::Database::Variant);
|
||||||
unsigned existing_results_for_pilot(unsigned pilot_id);
|
unsigned existing_results_for_pilot(unsigned pilot_id);
|
||||||
|
|
||||||
#ifndef __puma
|
#ifndef __puma
|
||||||
|
|||||||
Reference in New Issue
Block a user