fix(pipeline): let a finished render's preview outrank pending renders
Deploy / deploy (push) Successful in 6m11s
Deploy / deploy (push) Successful in 6m11s
Urgent already propagated — a preview inherits its render's priority, so an urgent export stays ahead all the way to QC. The complaint was the other half: at equal priority previews always ran last. The queue orders by priority then age, and a preview job is only created when its render finishes, so it is always newer than the renders queued beside it. Ten shots ran as ten renders and then ten previews, and nothing was reviewable until the end of the batch. render.previewPriorityBoost (default 1) subtracts from the render's priority when the preview is created, so a shot finishes end to end before the next render starts. The boost never promotes a job across the urgent threshold: a normal preview must not inherit permission to run outside the render window that its render never had. Set it to 0 for the old behaviour. Worth knowing separately: a worker will not claim preview jobs at all while an artist has AE open on that machine, which during the day is the larger reason previews appear to wait. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -177,6 +177,22 @@ export async function inheritPreviewMedia(
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* How a preview job is ranked against the render it follows.
|
||||
*
|
||||
* The preview is created when the render finishes, so with equal priority it
|
||||
* sorts behind every render queued at the same time — a batch runs as all the
|
||||
* renders, then all the previews, and nothing is reviewable until the end. The
|
||||
* boost lets a finished shot complete instead.
|
||||
*/
|
||||
export function previewPriority(renderPriority: number, boost: number, urgentThreshold: number): number {
|
||||
const boosted = renderPriority - Math.max(0, boost);
|
||||
// A boost must never promote a job across the urgent line: that would let it
|
||||
// claim outside the render window, which whoever queued it did not ask for.
|
||||
if (renderPriority > urgentThreshold && boosted <= urgentThreshold) return urgentThreshold + 1;
|
||||
return Math.max(0, boosted);
|
||||
}
|
||||
|
||||
/** Creates the PREVIEW_ONLY job that follows a successful EXR render. */
|
||||
export async function createPreviewJob(
|
||||
tx: Prisma.TransactionClient,
|
||||
@@ -185,13 +201,18 @@ export async function createPreviewJob(
|
||||
maxAttempts: number,
|
||||
priority: number
|
||||
) {
|
||||
const [boost, urgentThreshold] = await Promise.all([
|
||||
getConfigNumber("render.previewPriorityBoost"),
|
||||
getConfigNumber("render.urgentPriorityThreshold"),
|
||||
]);
|
||||
|
||||
return tx.renderJob.create({
|
||||
data: {
|
||||
type: "PREVIEW_ONLY",
|
||||
exportId: exportRow.id,
|
||||
attempt: 1,
|
||||
maxAttempts,
|
||||
priority,
|
||||
priority: previewPriority(priority, boost, urgentThreshold),
|
||||
manifest: manifest as unknown as Prisma.InputJsonValue,
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user