perf: warm CDP WebSocket browser pipeline for ResidentServer screenshots - #292
Open
IoannisMaras wants to merge 1 commit into
Open
perf: warm CDP WebSocket browser pipeline for ResidentServer screenshots#292IoannisMaras wants to merge 1 commit into
IoannisMaras wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Speed up screenshots using warm CDP WebSocket connection in ResidentServer
What this PR does
Spawning a fresh
chrome.exeprocess for every screenshot command was taking ~2.5 seconds per capture due to process creation, V8 startup, and disk file I/O.This PR connects Chrome to
ResidentServerusing Chrome DevTools Protocol (CDP) over a WebSocket connection:ResidentServerstarts, it opens a single background Chrome process (chrome-headless-shell,chrome, oredge) and keeps a WebSocket open to it.data:text/html;base64instead of writing temporary.htmlfiles to disk first.ResidentServer(or when runningofficecli close), it closes the WebSocket and kills the Chrome process cleanly so zero memory or CPU is leaked.Performance Results
When paired with PR #1 (PR #289), end-to-end screenshot execution time drops from ~2.4 seconds down to ~148 ms:
1. Cold Startup Phase (First time launching background server & browser)
mainCold Run: ~2,450 ms2. Warm Resident Execution Phase (Subsequent commands while active)
main: ~2,450 ms (spawns new Chrome process every single time)Execution Breakdown (~148 ms total)
officecli.exeprocess launch: ~105 msHow it was tested
.docx,.xlsx, and.pptx.officecli close.