Added: #1440 Test command for task queue loading

--HG--
branch : build_pipeline_v3
hg/feature/build_pipeline_v3
kaetemi 13 years ago
parent 1585931251
commit 369d73e7f6

@ -129,7 +129,7 @@ CBuildTaskInfo *CBuildTaskQueue::getTaskForSlave(const std::vector<uint32> &avai
m_Mutex.lock();
std::vector<CBuildTaskInfo *> availableTasks;
createBuildableTaskList(availableTasks, m_BypassDependencyError);
sortBuildableTaskListByMostDependents(availableTasks);
sortBuildableTaskListByMostWaitingDependents(availableTasks);
for (std::vector<CBuildTaskInfo *>::iterator it = availableTasks.begin(), end = availableTasks.end(); it != end; ++it)
{
CBuildTaskInfo *task = (*it);
@ -243,9 +243,23 @@ uint CBuildTaskQueue::countRemainingBuildableTasksAndWorkingTasks()
void CBuildTaskQueue::listTaskQueueByMostDependents(std::vector<CBuildTaskInfo *> &result)
{
result.clear();
result.reserve(m_Tasks.size());
/*copy(m_Tasks.begin(), m_Tasks.end(), result);
sortBuildableTaskListByMostDependents(result);*/
result = m_Tasks; // copy
sortBuildableTaskListByMostDependents(result);
}
void CBuildTaskQueue::countWaitingDependents(uint &dependentResult, CBuildTaskInfo *taskInfo)
{
uint nb = 0;
for (std::vector<uint16>::size_type i = 0; i < m_Tasks.size(); ++i)
if (m_Tasks[i]->State == TASK_WAITING && doesTaskDependOnTask(m_Tasks[i], taskInfo)) ++nb;
dependentResult = nb;
}
void CBuildTaskQueue::flagWaitingDependents(std::vector<bool> &dependentResult, CBuildTaskInfo *taskInfo)
{
dependentResult.resize(m_Tasks.size());
for (std::vector<bool>::size_type i = 0; i < dependentResult.size(); ++i)
dependentResult[i] = (m_Tasks[i]->State == TASK_WAITING && doesTaskDependOnTask(m_Tasks[i], taskInfo));
}
void CBuildTaskQueue::countDependents(uint &dependentResult, CBuildTaskInfo *taskInfo)
@ -330,6 +344,29 @@ void CBuildTaskQueue::sortBuildableTaskListByMostDependents(std::vector<CBuildTa
} while (sc != 0);
}
void CBuildTaskQueue::sortBuildableTaskListByMostWaitingDependents(std::vector<CBuildTaskInfo *> &result)
{
// brings most urgent tasks on top
std::vector<uint> dependentsCache;
dependentsCache.resize(result.size());
for (std::vector<uint>::size_type i = 0; i < dependentsCache.size(); ++i)
countWaitingDependents(dependentsCache[i], result[i]);
uint sc;
do
{
sc = 0;
for (std::vector<uint>::size_type i = 0; i < dependentsCache.size() - 1; ++i)
{
if (dependentsCache[i + 1] > dependentsCache[i])
{
swap(dependentsCache[i], dependentsCache[i + 1]);
swap(result[i], result[i + 1]);
++sc;
}
}
} while (sc != 0);
}
} /* namespace PIPELINE */
/* end of file */

@ -121,6 +121,10 @@ public:
private:
// void countDependencies(uint &waitingResult, uint &failAbortResult, CBuildTaskInfo *taskInfo);
/// Same as next but only counts depending tasks that are waiting.
void countWaitingDependents(uint &dependentResult, CBuildTaskInfo *taskInfo);
void flagWaitingDependents(std::vector<bool> &dependentResult, CBuildTaskInfo *taskInfo);
/// Recursively count the number of tasks that depend on this task.
void countDependents(uint &dependentResult, CBuildTaskInfo *taskInfo);
void flagDependents(std::vector<bool> &dependentResult, CBuildTaskInfo *taskInfo);
@ -129,6 +133,7 @@ private:
void createBuildableTaskList(std::vector<CBuildTaskInfo *> &result, bool bypassError);
void sortBuildableTaskListByMostDependents(std::vector<CBuildTaskInfo *> &result);
void sortBuildableTaskListByMostWaitingDependents(std::vector<CBuildTaskInfo *> &result);
}; /* class CBuildTaskQueue */

@ -56,6 +56,7 @@
#include "pipeline_interface_impl.h"
#include "pipeline_process_impl.h"
#include "../plugin_library/process_info.h"
#include "build_task_queue.h"
// using namespace std;
using namespace NLMISC;
@ -720,6 +721,35 @@ NLMISC_COMMAND(showDependencies, "Show dependencies.", "<projectName> <processNa
return true;
}
NLMISC_COMMAND(dumpTestTaskQueueLoad, "Test task queue generation. You MUST NOT reload workspace sheets while running this.", "")
{
if(args.size() != 0) return false;
log.displayNL("**********************************************************************");
PIPELINE::CBuildTaskQueue taskQueue;
taskQueue.loadQueue(PIPELINE::g_PipelineWorkspace, false);
std::vector<PIPELINE::CBuildTaskInfo *> tasks;
taskQueue.listTaskQueueByMostDependents(tasks);
log.displayNL("COUNT: %i", tasks.size());
for (std::vector<PIPELINE::CBuildTaskInfo *>::iterator it = tasks.begin(), end = tasks.end(); it != end; ++it)
{
PIPELINE::CBuildTaskInfo *task = *it;
PIPELINE::CProcessPluginInfo pluginInfo;
PIPELINE::g_PipelineWorkspace->getProcessPlugin(pluginInfo, task->ProcessPluginId);
log.displayNL("TASK: %i: %s, %s", task->Id.Global, task->ProjectName.c_str(), pluginInfo.Handler.c_str());
}
taskQueue.abortQueue();
log.displayNL("**********************************************************************");
return true;
}
NLNET_SERVICE_MAIN(PIPELINE::CPipelineService, PIPELINE_SHORT_SERVICE_NAME, PIPELINE_LONG_SERVICE_NAME, 0, PIPELINE::s_ShardCallbacks, PIPELINE_SERVICE_DIRECTORY, PIPELINE_SERVICE_DIRECTORY)
/* end of file */

Loading…
Cancel
Save