Skip to content

Comments

Profiling, benchmarking instrumentation and optimization plan#322

Open
prk-Jr wants to merge 7 commits intomainfrom
feat/optimize-ts
Open

Profiling, benchmarking instrumentation and optimization plan#322
prk-Jr wants to merge 7 commits intomainfrom
feat/optimize-ts

Conversation

@prk-Jr
Copy link
Collaborator

@prk-Jr prk-Jr commented Feb 18, 2026

Summary

  • Add OPTIMIZATION.md — WASM guest profiling results, CPU breakdown, and phased optimization plan.
  • Add scripts/profile.sh for WASM guest profiling via fastly compute serve --profile-guest (Firefox Profiler-compatible output)
  • Add scripts/benchmark.sh for TTFB analysis, cold start detection, endpoint latency breakdown, and load testing with --save/--compare support

Test plan

  • cargo test passes (no code changes, tooling and docs only)
  • Run ./scripts/profile.sh and verify flame graph output in benchmark-results/profiles/
  • Run ./scripts/benchmark.sh --quick against local Viceroy and verify output
  • Team review of OPTIMIZATION.md — especially "Decisions Needed" section

Introduce RequestTimer for per-request phase tracking (init, backend,
process, total) exposed via Server-Timing response headers. Add
benchmark tooling with --profile mode for collecting timing data.
Document phased optimization plan covering streaming architecture,
code-level fixes, and open design questions for team review.
Introduce RequestTimer for per-request phase tracking (init, backend,
process, total) exposed via Server-Timing response headers. Add
benchmark tooling with --profile mode for collecting timing data.
Document phased optimization plan covering streaming architecture,
code-level fixes, and open design questions for team review.
@aram356
Copy link
Collaborator

aram356 commented Feb 18, 2026

@prk-Jr Have you seen this? https://www.fastly.com/blog/profiling-fastly-compute-applications

I don't think we need to make changes to profile

RequestTimer and Server-Timing header were premature — WASM guest
profiling via profile.sh gives better per-function visibility without
runtime overhead. Also strips dead --profile mode from benchmark.sh.
build.rs already resolves trusted-server.toml + env vars at compile time
and embeds the result. Replace Settings::from_toml() with direct
toml::from_str() to skip the config crate pipeline on every request.
Profiling confirms: ~5-8% → ~3.3% CPU per request.
@prk-Jr prk-Jr linked an issue Feb 19, 2026 that may be closed by this pull request
- OPTIMIZATION.md: profiling results, CPU breakdown, phased optimization
  plan covering streaming fixes, config crate elimination, and
  stream_to_client() architecture
- scripts/profile.sh: WASM guest profiling via --profile-guest with
  Firefox Profiler-compatible output
- scripts/benchmark.sh: TTFB analysis, cold start detection, endpoint
  latency breakdown, and load testing with save/compare support
@prk-Jr prk-Jr changed the title Add Server-Timing instrumentation and optimization plan Profiling, benchmarking instrumentation and optimization plan Feb 19, 2026
@aram356 aram356 marked this pull request as ready for review February 23, 2026 16:44
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.

Document and investigate metrics for request and response

2 participants