dpgaspar opened a new pull request, #41243: URL: https://github.com/apache/superset/pull/41243
### SUMMARY The Playwright implementation spawns a brand-new Chromium process for every single screenshot task. Each Chromium instance consumes ~100-150 MB and the constant create/destroy cycle adds GC pressure and memory fragmentation. This PR introduces a per-worker-process browser manager (`_PlaywrightBrowserManager`) that: - **Lazily creates** a single Chromium browser per Celery worker process (after fork, avoiding Playwright fork-safety issues) - **Reuses the browser** across tasks, creating only lightweight isolated **browser contexts** per task (~1ms vs ~500ms-1s for a full browser launch) - **Auto-recovers** from browser crashes via `is_connected()` check - **Cleans up** via `atexit` on process exit This is safe because Celery's prefork model runs tasks **sequentially** within each worker process — there is no concurrent access to the browser instance. ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF N/A — backend performance improvement, no UI changes. ### TESTING INSTRUCTIONS - Deploy to a staging environment with Playwright enabled (`PLAYWRIGHT_REPORTS_AND_THUMBNAILS` feature flag) - Trigger multiple screenshot tasks (e.g., dashboard thumbnail generation) - Verify screenshots are generated correctly - Monitor worker memory — should see reduced peak memory and less fragmentation vs. baseline - Verify that if the browser crashes mid-task, the next task recovers automatically ### ADDITIONAL INFORMATION - [ ] Has associated issue: - [ ] Required feature flags: - [ ] Changes UI - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351)) - [ ] Migration is atomic, supports rollback & is backwards-compatible - [ ] Confirm DB migration upgrade and downgrade tested - [ ] Runtime estimates and downtime expectations provided - [ ] Introduces new feature or API - [ ] Removes existing feature or API -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
