@@ -131,6 +131,8 @@ export interface WorkerSizingConfig extends Partial<
131131 * than a plain DOM screenshot. Explicit --workers requests ignore this hint.
132132 */
133133 captureCostMultiplier ?: number ;
134+ /** macOS, hardware GPU, screenshot frames written to disk (not streamed through this process). */
135+ appleGpuDiskCapture ?: boolean ;
134136}
135137
136138type WorkerBrowserPoolDecision = {
@@ -151,6 +153,10 @@ const HEAP_RESERVED_MB = 1024;
151153// default heap ⇒ >~500MB/worker + base. Caps auto sizing; an explicit
152154// `--workers N` is still the operator's call.
153155const HEAP_PER_WORKER_MB = 640 ;
156+ // Apple-GPU disk capture measured ~15-25 MB parent heap per worker; 14 cores kept gaining to 8.
157+ const APPLE_DISK_HEAP_PER_WORKER_MB = 128 ;
158+ const APPLE_DISK_CORES_PER_WORKER = 1.75 ;
159+ const APPLE_DISK_MAX_WORKERS = 8 ;
154160const MIN_WORKERS = 1 ;
155161const MAX_WORKER_DIAGNOSTIC_LINES = 8 ;
156162// Hard ceiling on explicit `--workers N` requests. Above this, the cost of
@@ -321,9 +327,13 @@ export function computeWorkerSizing(
321327 // is immediately reclaimable.
322328 const totalMemoryMb = getSystemTotalMb ( ) ;
323329 const heapLimitMb = Math . round ( getHeapStatistics ( ) . heap_size_limit / ( 1024 * 1024 ) ) ;
330+ const appleDisk = config ?. appleGpuDiskCapture === true ;
324331 const heapBasedWorkers = Math . max (
325332 1 ,
326- Math . floor ( ( heapLimitMb - HEAP_RESERVED_MB ) / HEAP_PER_WORKER_MB ) ,
333+ Math . floor (
334+ ( heapLimitMb - HEAP_RESERVED_MB ) /
335+ ( appleDisk ? APPLE_DISK_HEAP_PER_WORKER_MB : HEAP_PER_WORKER_MB ) ,
336+ ) ,
327337 ) ;
328338 const cpuBasedWorkers = Math . max ( 1 , cpuCount - 2 ) ;
329339 const memoryBasedWorkers = Math . max ( 1 , Math . floor ( ( totalMemoryMb * 0.5 ) / MEMORY_PER_WORKER_MB ) ) ;
@@ -362,9 +372,15 @@ export function computeWorkerSizing(
362372 if ( concurrency !== "auto" ) {
363373 return Math . max ( MIN_WORKERS , Math . min ( ABSOLUTE_MAX_WORKERS , Math . floor ( concurrency ) ) ) ;
364374 }
365- return defaultSafeMaxWorkers ( ) ;
375+ return appleDisk
376+ ? Math . max ( defaultSafeMaxWorkers ( ) , APPLE_DISK_MAX_WORKERS )
377+ : defaultSafeMaxWorkers ( ) ;
366378 } ) ( ) ;
367- const effectiveCoresPerWorker = config ?. coresPerWorker ?? DEFAULT_CONFIG . coresPerWorker ;
379+ const configuredCoresPerWorker = config ?. coresPerWorker ?? DEFAULT_CONFIG . coresPerWorker ;
380+ const effectiveCoresPerWorker =
381+ appleDisk && configuredCoresPerWorker === DEFAULT_CONFIG . coresPerWorker
382+ ? APPLE_DISK_CORES_PER_WORKER
383+ : configuredCoresPerWorker ;
368384 const effectiveMinParallelFrames = config ?. minParallelFrames ?? DEFAULT_CONFIG . minParallelFrames ;
369385 const effectiveLargeRenderThreshold =
370386 config ?. largeRenderThreshold ?? DEFAULT_CONFIG . largeRenderThreshold ;
0 commit comments