Skip to content

benchmark: measure Lightpanda startup until CDP is ready - #32

Open
krichprollsch wants to merge 1 commit into
dust-tt:mainfrom
krichprollsch:lightpanda-benchmark-update
Open

benchmark: measure Lightpanda startup until CDP is ready#32
krichprollsch wants to merge 1 commit into
dust-tt:mainfrom
krichprollsch:lightpanda-benchmark-update

Conversation

@krichprollsch

Copy link
Copy Markdown

Here is an update of the Lightpanda benchmark introduced by #28

Problem

startLightpanda() in benchmarks/compare.ts resolved after a hardcoded
setTimeout(..., 1500). That meant the reported "startup" figure for Lightpanda
was really just the sleep constant — it did not measure anything about the
browser, and it was not comparable to the Chrome number, which comes from
puppeteer.launch() (i.e. time until the browser is actually usable).

Teardown had the same problem in reverse: proc.kill() followed by a blind
500 ms sleep to "let the port be released".

Change

  • startLightpanda() now polls puppeteer.connect() until it succeeds and
    returns the connected Browser alongside the process. The measured duration
    is now "time until the browser accepts a CDP connection", which is the same
    thing puppeteer.launch() measures for Chrome.
    • 10 s deadline, with a clear error if the browser never becomes ready.
    • Fails fast with an actionable message if the process exits during startup
      (the common cause being port 9222 already in use).
  • Added stopLightpanda(), which waits on the process exit event instead of
    sleeping a fixed 500 ms.
  • benchmarkLightpanda() reuses the Browser returned by startLightpanda()
    rather than opening a second connection outside the measured region — the
    previous code paid the connect cost twice and excluded it from the timing.
  • ITERATIONS 5 → 100, TEST_URL example.comexample.org.

Results

Run on this branch, 100 iterations per browser, Chrome
/usr/bin/google-chrome, Lightpanda 1.0.0-nightly.8285+de85a51d:

Browser Metric Avg (ms) Min (ms) Max (ms)
Chrome Startup 140.8 120.8 276.8
Chrome Navigation 338.5 97.3 1578.6
Lightpanda Startup 21.9 18.4 29.7
Lightpanda Navigation 70.3 51.9 165.0

Startup speedup: 6.4x

startLightpanda() now polls puppeteer.connect() until it succeeds (10s
deadline, fails fast if the process exits early) and returns the connected
Browser, so the measured startup time is comparable to puppeteer.launch()
for Chrome — "time until usable" instead of "time until spawn() returned".
The previous fixed 1500ms sleep both inflated the number and made it
independent of actual startup cost.

Teardown waits for the process exit event instead of sleeping 500ms.
Bump ITERATIONS to 100 and switch TEST_URL to example.org.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant