/** * Renderer Concurrency Layer * * Manages concurrency control for the shared multi-tenant renderer: * - Global render semaphore (limits total concurrent renders per pod) * - Per-project slot management (noisy-neighbor protection) * - Mutex-based locking for race-free slot acquisition * * @module rendering/renderer-concurrency */ import { Semaphore } from "../modules/react-loader/ssr-module-loader/concurrency/semaphore.js"; /** * Maximum concurrent renders per pod. * Configurable via RENDER_MAX_CONCURRENT env var. * Prevents one pod from being overwhelmed when multiple projects have issues. */ export declare const RENDER_MAX_CONCURRENT: number; /** * Maximum concurrent renders per project (noisy-neighbor protection). * Defaults to ceil(RENDER_MAX_CONCURRENT / 3) so no single project can consume * more than ~1/3 of pod capacity. Set to 0 to disable per-project limits. * Configurable via RENDER_PER_PROJECT_LIMIT env var. */ export declare const RENDER_PER_PROJECT_LIMIT: number; /** * Maximum queued foreground renders per project. * Defaults to one additional per-project concurrency window. Background work * never enters this queue. */ export declare const RENDER_PER_PROJECT_QUEUE_SIZE: number; /** Maximum requests that may wait on one deduplicated cacheable render. */ export declare const RENDER_SINGLEFLIGHT_MAX_FOLLOWERS: number; /** * Timeout for acquiring render permit (ms). * This is the total foreground admission budget across project and global * capacity gates. Background work does not wait. */ export declare const RENDER_ACQUIRE_TIMEOUT_MS = 5000; /** * Promise-based mutex with atomic lock state transitions. * No TOCTOU race: `acquire()` synchronously marks the lock as held when * uncontested, and `release()` atomically hands the lock to the next waiter. */ export declare class Mutex { private queue; private locked; acquire(timeoutMs?: number): Promise<() => void>; private release; get waiting(): number; } export declare const renderSemaphore: Semaphore; /** * Per-project active render counter. Prevents a single noisy tenant from * monopolizing the global semaphore and starving other projects. * Only enforced when RENDER_PER_PROJECT_LIMIT > 0. */ export declare const projectRenderCounts: Map; /** * Attempt to acquire a project render slot with proper locking. Foreground * callers may opt into a bounded FIFO wait; background callers use the * fail-fast default. */ export declare function acquireProjectSlot(projectId: string, options?: { wait?: boolean; timeoutMs?: number; signal?: AbortSignal; }): Promise; /** * Release a project render slot with proper locking. */ export declare function releaseProjectSlot(projectId: string): Promise; //# sourceMappingURL=renderer-concurrency.d.ts.map