feat(init): add cold-start init-phase timing instrumentation#1271
Draft
duncanista wants to merge 1 commit into
Draft
feat(init): add cold-start init-phase timing instrumentation#1271duncanista wants to merge 1 commit into
duncanista wants to merge 1 commit into
Conversation
Contributor
|
815f22a to
2dd3d75
Compare
Add debug-gated checkpoints at the key cold-start init boundaries (crypto provider, TLS client build, config parse, shared client, register, dogstatsd, trace agent, telemetry subscribe, ready), plus a one-time available_parallelism() log. Each checkpoint logs delta (time since the previous checkpoint = that phase's own cost) and cumulative (time since process start), in milliseconds to 6 decimal places (nanosecond resolution) so sub-millisecond phases are visible. Init time is attributed per phase directly, with no manual subtraction. The per-phase bookkeeping is guarded behind a DEBUG-level check, so it stays effectively free at the default info level. This is the measurement prerequisite (H0) for the cold-start improvements.
2dd3d75 to
d46a7ec
Compare
This was referenced Jun 24, 2026
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.
Please include Jira ticket in title. (no ticket yet — add your SLS ticket before marking ready for review.)
Overview
Adds debug-gated init-phase timing instrumentation to the extension entry point so cold-start (initialization) time can be attributed per phase and measured rather than guessed. This is the measurement prerequisite (H0) for the cold-start improvement effort.
A small helper
log_init_checkpoint(start_time, phase)is called at each key boundary inmain()/extension_loop_active()and logs both:delta— time since the previous checkpoint (that phase's own cost), andcumulative— time since process start,in milliseconds to 6 decimal places (nanosecond resolution), so sub-millisecond phases are visible and per-phase cost is read directly off each line — no subtracting consecutive values by hand. Phases:
crypto_provider_ready→tls_client_build→config_parse→shared_client_ready→register_ready→dogstatsd_started→trace_agent_started→telemetry_subscribed→readyThese isolate the costs the cold-start work targets — e.g.
tls_client_buildandshared_client_readyare the two redundant reqwest/TLS client builds (H1),register_ready/telemetry_subscribedare the two Extensions-API round-trips (H2). It also logsavailable_parallelism()once — the value Tokio sizes its worker pool from, which varies per Lambda memory tier (H15).Example output (only at
DD_LOG_LEVEL=debug):Notes
infolevel: the per-phase bookkeeping (clock read + atomic) is guarded behind aDEBUG-level check and returns early otherwise; nothing is logged or computed.AtomicU64of nanos (checkpoints run sequentially on the init path;saturating_subguards against any reordering).grep 'INIT |'yields the full timeline as one series.Testing
cargo clippy --bin bottlecap— clean (crate deniesclippy::all+clippy::pedantic+clippy::unwrap_used).cargo fmt— clean.DD_LOG_LEVEL=debugvia thelocal_tests/RIE harness and confirm theINIT |series prints, deltas are non-negative, and they sum to ~the existing "ready in {}ms" total. Usescripts/bench.sh+scripts/report_stats.pyto capture deployed cold-startInit Durationdeltas.