|
@@ -180,13 +180,13 @@ public:
|
|
|
float finalProgress = activeJobs[request.id].progress;
|
|
float finalProgress = activeJobs[request.id].progress;
|
|
|
auto completionTime = std::chrono::system_clock::now();
|
|
auto completionTime = std::chrono::system_clock::now();
|
|
|
auto totalGenerationTime = std::chrono::duration_cast<std::chrono::milliseconds>(completionTime - startTime).count();
|
|
auto totalGenerationTime = std::chrono::duration_cast<std::chrono::milliseconds>(completionTime - startTime).count();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
LOG_DEBUG("[TIMING_ANALYSIS] Job " + request.id +
|
|
LOG_DEBUG("[TIMING_ANALYSIS] Job " + request.id +
|
|
|
" - Total generation time: " + std::to_string(totalGenerationTime) + "ms");
|
|
" - Total generation time: " + std::to_string(totalGenerationTime) + "ms");
|
|
|
LOG_DEBUG("[JOB_COMPLETION] Job " + request.id +
|
|
LOG_DEBUG("[JOB_COMPLETION] Job " + request.id +
|
|
|
" - Status changing to '" + (result.success ? "completed" : "failed") + "'" +
|
|
" - Status changing to '" + (result.success ? "completed" : "failed") + "'" +
|
|
|
" - Progress at completion: " + std::to_string(static_cast<int>(finalProgress * 100.0f)) + "%");
|
|
" - Progress at completion: " + std::to_string(static_cast<int>(finalProgress * 100.0f)) + "%");
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
activeJobs[request.id].status = result.success ? GenerationStatus::COMPLETED : GenerationStatus::FAILED;
|
|
activeJobs[request.id].status = result.success ? GenerationStatus::COMPLETED : GenerationStatus::FAILED;
|
|
|
activeJobs[request.id].endTime = endTime;
|
|
activeJobs[request.id].endTime = endTime;
|
|
|
|
|
|
|
@@ -254,7 +254,7 @@ public:
|
|
|
if (it != activeJobs.end()) {
|
|
if (it != activeJobs.end()) {
|
|
|
// Clamp model loading progress to valid range [0.0, 1.0]
|
|
// Clamp model loading progress to valid range [0.0, 1.0]
|
|
|
modelProgress = std::max(0.0f, std::min(1.0f, modelProgress));
|
|
modelProgress = std::max(0.0f, std::min(1.0f, modelProgress));
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
it->second.modelLoadProgress = modelProgress;
|
|
it->second.modelLoadProgress = modelProgress;
|
|
|
it->second.generationProgress = 0.0f;
|
|
it->second.generationProgress = 0.0f;
|
|
|
// Overall progress during model loading is just the model loading progress
|
|
// Overall progress during model loading is just the model loading progress
|
|
@@ -283,7 +283,7 @@ public:
|
|
|
if (it != activeJobs.end()) {
|
|
if (it != activeJobs.end()) {
|
|
|
// Clamp generation progress to valid range [0.0, 1.0]
|
|
// Clamp generation progress to valid range [0.0, 1.0]
|
|
|
genProgress = std::max(0.0f, std::min(1.0f, genProgress));
|
|
genProgress = std::max(0.0f, std::min(1.0f, genProgress));
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
it->second.generationProgress = genProgress;
|
|
it->second.generationProgress = genProgress;
|
|
|
it->second.currentStep = step;
|
|
it->second.currentStep = step;
|
|
|
it->second.totalSteps = totalSteps;
|
|
it->second.totalSteps = totalSteps;
|
|
@@ -291,19 +291,20 @@ public:
|
|
|
|
|
|
|
|
// Handle first generation callback specially
|
|
// Handle first generation callback specially
|
|
|
if (it->second.firstGenerationCallback) {
|
|
if (it->second.firstGenerationCallback) {
|
|
|
- // This is the first callback, reset generation progress to start from 0.0
|
|
|
|
|
|
|
+ // This is the first callback, ignore the incoming genProgress value
|
|
|
// and set overall progress to exactly 50% (model loading complete)
|
|
// and set overall progress to exactly 50% (model loading complete)
|
|
|
it->second.generationProgress = 0.0f;
|
|
it->second.generationProgress = 0.0f;
|
|
|
it->second.progress = 0.5f;
|
|
it->second.progress = 0.5f;
|
|
|
it->second.firstGenerationCallback = false; // Mark that we've handled the first callback
|
|
it->second.firstGenerationCallback = false; // Mark that we've handled the first callback
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
LOG_DEBUG("First generation callback for job " + jobId +
|
|
LOG_DEBUG("First generation callback for job " + jobId +
|
|
|
- " - Reset generation progress to 0.0 and overall progress to 50%");
|
|
|
|
|
|
|
+ " - Ignored genProgress (" + std::to_string(genProgress) +
|
|
|
|
|
+ "), reset generation progress to 0.0 and overall progress to 50%");
|
|
|
} else {
|
|
} else {
|
|
|
// For subsequent callbacks, calculate overall progress normally: 50% for model loading + 50% for generation
|
|
// For subsequent callbacks, calculate overall progress normally: 50% for model loading + 50% for generation
|
|
|
it->second.progress = 0.5f + (genProgress * 0.5f);
|
|
it->second.progress = 0.5f + (genProgress * 0.5f);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Clamp overall progress to valid range [0.0, 1.0]
|
|
// Clamp overall progress to valid range [0.0, 1.0]
|
|
|
it->second.progress = std::max(0.0f, std::min(1.0f, it->second.progress));
|
|
it->second.progress = std::max(0.0f, std::min(1.0f, it->second.progress));
|
|
|
|
|
|
|
@@ -341,8 +342,6 @@ public:
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // Update job status to MODEL_LOADING if model needs to be loaded
|
|
|
|
|
- bool modelNeededLoading = false;
|
|
|
|
|
if (!modelManager->isModelLoaded(request.modelName)) {
|
|
if (!modelManager->isModelLoaded(request.modelName)) {
|
|
|
// Update status to show model is being loaded
|
|
// Update status to show model is being loaded
|
|
|
{
|
|
{
|
|
@@ -382,8 +381,6 @@ public:
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- modelNeededLoading = true;
|
|
|
|
|
-
|
|
|
|
|
// Reset status after successful model loading
|
|
// Reset status after successful model loading
|
|
|
{
|
|
{
|
|
|
std::lock_guard<std::mutex> lock(jobsMutex);
|
|
std::lock_guard<std::mutex> lock(jobsMutex);
|
|
@@ -570,18 +567,18 @@ public:
|
|
|
// Save generated images to files
|
|
// Save generated images to files
|
|
|
LOG_DEBUG("[TIMING_ANALYSIS] Job " + request.id + " - Starting post-processing (image saving) phase");
|
|
LOG_DEBUG("[TIMING_ANALYSIS] Job " + request.id + " - Starting post-processing (image saving) phase");
|
|
|
auto postProcessingStart = std::chrono::system_clock::now();
|
|
auto postProcessingStart = std::chrono::system_clock::now();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
for (size_t i = 0; i < generatedImages.size(); i++) {
|
|
for (size_t i = 0; i < generatedImages.size(); i++) {
|
|
|
const auto& image = generatedImages[i];
|
|
const auto& image = generatedImages[i];
|
|
|
LOG_DEBUG("[TIMING_ANALYSIS] Job " + request.id + " - Saving image " + std::to_string(i+1) + "/" + std::to_string(generatedImages.size()));
|
|
LOG_DEBUG("[TIMING_ANALYSIS] Job " + request.id + " - Saving image " + std::to_string(i+1) + "/" + std::to_string(generatedImages.size()));
|
|
|
auto imageSaveStart = std::chrono::system_clock::now();
|
|
auto imageSaveStart = std::chrono::system_clock::now();
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
std::string imagePath = saveImageToFile(image, request.id, i);
|
|
std::string imagePath = saveImageToFile(image, request.id, i);
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
auto imageSaveEnd = std::chrono::system_clock::now();
|
|
auto imageSaveEnd = std::chrono::system_clock::now();
|
|
|
auto imageSaveTime = std::chrono::duration_cast<std::chrono::milliseconds>(imageSaveEnd - imageSaveStart).count();
|
|
auto imageSaveTime = std::chrono::duration_cast<std::chrono::milliseconds>(imageSaveEnd - imageSaveStart).count();
|
|
|
LOG_DEBUG("[TIMING_ANALYSIS] Job " + request.id + " - Image " + std::to_string(i+1) + " save took " + std::to_string(imageSaveTime) + "ms");
|
|
LOG_DEBUG("[TIMING_ANALYSIS] Job " + request.id + " - Image " + std::to_string(i+1) + " save took " + std::to_string(imageSaveTime) + "ms");
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if (!imagePath.empty()) {
|
|
if (!imagePath.empty()) {
|
|
|
result.imagePaths.push_back(imagePath);
|
|
result.imagePaths.push_back(imagePath);
|
|
|
} else {
|
|
} else {
|
|
@@ -589,7 +586,7 @@ public:
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
auto postProcessingEnd = std::chrono::system_clock::now();
|
|
auto postProcessingEnd = std::chrono::system_clock::now();
|
|
|
auto postProcessingTime = std::chrono::duration_cast<std::chrono::milliseconds>(postProcessingEnd - postProcessingStart).count();
|
|
auto postProcessingTime = std::chrono::duration_cast<std::chrono::milliseconds>(postProcessingEnd - postProcessingStart).count();
|
|
|
LOG_DEBUG("[TIMING_ANALYSIS] Job " + request.id + " - Post-processing completed in " + std::to_string(postProcessingTime) + "ms");
|
|
LOG_DEBUG("[TIMING_ANALYSIS] Job " + request.id + " - Post-processing completed in " + std::to_string(postProcessingTime) + "ms");
|
|
@@ -1272,7 +1269,7 @@ public:
|
|
|
return ss.str();
|
|
return ss.str();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
// Helper function to populate JobInfo from GenerationRequest
|
|
// Helper function to populate JobInfo from GenerationRequest
|
|
|
void populateJobInfoFromRequest(JobInfo& jobInfo, const GenerationRequest& request) {
|
|
void populateJobInfoFromRequest(JobInfo& jobInfo, const GenerationRequest& request) {
|
|
|
// Model information
|
|
// Model information
|