Skip to content

Boot-time profiling: span instrumentation + benchmark harness - #588

Closed
lisachenko wants to merge 1 commit into
masterfrom
claude/goaop-boot-time-profiling-gn47tf
Closed

Boot-time profiling: span instrumentation + benchmark harness#588
lisachenko wants to merge 1 commit into
masterfrom
claude/goaop-boot-time-profiling-gn47tf

Conversation

@lisachenko

Copy link
Copy Markdown
Member

What

First step of the hot-start boot-time optimization work for 4.0: measurement infrastructure.

  • Go\Instrument\BootTimer — a tiny boot profiler that is disabled unless the GO_AOP_BENCH_SPANS env var points to an output file (a single static bool check per call when off, so it can live in the hot path permanently). Records hrtime spans with per-span autoloaded-file and memory deltas, plus aggregate counters, and dumps a JSON report on shutdown.
  • Span hooks around each boot phase: AspectKernel::init sub-steps (normalizeOptions, container construction, stream-filter registration, transformer registration, composer-loader init, configureAop), per-service Container::addLazyService, the _transformation.cache include in CachePathManager, AopComposerLoader::findFile (composer lookup / realpath / cache-hit / filter-rewrite counters), and the transformer cold path (SourceTransformingLoader::filter parse, CachingTransformer weave + cached-reparse).
  • tests/Benchmark/bench-request.php simulates one request against the fixture project (kernel boot + autoload of woven classes + first intercepted call); run-bench.php orchestrates the cold/warm matrix across PHP binaries, using an opcache file cache to emulate a persistent server opcache in CLI runs, and reports median/p10/p90.
  • Fixture project: new production configuration profile (debug => false, isolated cache dir) so the warm-cache production fast path can be measured next to the existing debug profile.

Why

Baseline numbers and a per-phase breakdown are needed before the planned 4.0 boot-time optimizations (lazy transformer registration, truly-lazy container services, lazy aspect registration, real PREBUILT_CACHE mode, opcache-friendly cache state). Follow-up commits on this branch will add the measured results and the optimizations themselves.

Notes

  • No behavior change when GO_AOP_BENCH_SPANS is not set.
  • Benchmark results and analysis will be posted on this PR once the matrix (PHP 8.4/8.5/8.6 × cold/warm × debug/production) has been run.

🤖 Generated with Claude Code

https://claude.ai/code/session_01V1Z87HZ2iz23WPTtTYqFxE


Generated by Claude Code

…rness

Adds Go\Instrument\BootTimer (enabled only when GO_AOP_BENCH_SPANS is set,
single static bool check when off) with hrtime spans around each boot phase
of AspectKernel::init, per-lazy-service container registration, cache-state
include, autoloader findFile and transformer hot spots.

Adds tests/Benchmark/{bench-request,run-bench}.php: simulated fixture-app
request (boot + woven class autoload + first intercepted call) and a matrix
orchestrator (cold/warm, opcache file cache to emulate persistent opcache,
median/p10/p90 over N runs). Adds a 'production' (debug=false) profile to
the fixture project configuration with an isolated cache directory.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V1Z87HZ2iz23WPTtTYqFxE
@lisachenko

Copy link
Copy Markdown
Member Author

It isn’t valid direction to commit this into main code and PR. Declining this - only for local development and checks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants