Repository navigation
perf(serverless): defer CPU probe off worker import path - #629
Merged
Merged
Conversation
There was a problem hiding this comment.
馃煝 Approval recommended
The focused change preserves debugger output and fallback behavior, with targeted regression coverage and no unresolved findings.
No open issues 馃帀
What changed in this PR
Defers CPU detection until debugger output is requested, reducing serverless worker startup overhead.
Changes:
- Replaces the eager CPU probe with a cached, lazy lookup.
- Preserves the missing-processor fallback.
- Adds regression tests for lazy loading, caching, and debugger output.
| File | Description |
|---|---|
| tests/鈥媡est_serverless/鈥媡est_utils/鈥媡est_debugger.py | Tests processor caching, fallback, and output. |
| tests/鈥媡est_performance/鈥媡est_cold_start.py | Checks worker imports do not load cpuinfo. |
| runpod/鈥媠erverless/鈥媢tils/鈥媟p_debugger.py | Defers and caches CPU detection. |
Review effort: Balanced
7 tasks done
jasonwang-runpod
approved these changes
Oct 19, 2026
deanq
force-pushed
the
deanq/sls-808-lazy-cpu-probe
branch
from
October 19, 2026 17:21
42b63a5 to
e939086
Compare
rp_debugger called cpuinfo.get_cpu_info() at module level, and rp_job imports rp_debugger unconditionally, so every serverless worker paid a ~75ms CPU probe at startup. The result is only used when a job enables rp_debugger. - Replace the PROCESSOR constant with a cached get_processor_info(), resolved on first debugger output; import cpuinfo lazily inside it - Add a cold-start test asserting cpuinfo is not loaded by rp_job - import runpod.serverless: ~240ms -> ~162ms (macOS, warm) SLS-808
deanq
force-pushed
the
deanq/sls-808-lazy-cpu-probe
branch
from
October 19, 2026 17:47
e939086 to
031b658
Compare
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.
Summary
rp_debuggerrancpuinfo.get_cpu_info()at module level.rp_jobimportsrp_debuggerunconditionally, so every serverless worker paid the CPU probe at startup, even though the value is only used when a job setsrp_debugger: true.PROCESSORconstant replaced by a cachedget_processor_info(), resolved on first debugger outputimport cpuinfomoved inside itbrand_rawstill falls back to"Unable to get processor info."The module-level
PROCESSORname is removed; nothing in the SDK referenced it outside the old test.Impact
On x86 the probe is much more expensive than on macOS: py-cpuinfo measures clock speed in a child process around a fixed
sleep(1)(CPUID.get_raw_hz). On arm64 it skips that path.Measured on a real RTX 4090 serverless worker (AMD EPYC 7B13, 128 CPUs):
cpuinfo.get_cpu_info()"cpuinfo" in sys.moduleswasFalseinside the handler with the lazy probe. Locally,import runpod.serverless: ~240ms -> ~162ms (macOS arm64, warm, best of 3).Test plan
cpuinfois not insys.modulesafter importingrp_job(fails on main)brand_raw; debugger output includes processormake quality-check: 1446 passed, 91.8% coverageLinear: SLS-808, SLS-814