## Summary TLS initialization (~95ms) previously blocked the critical path at the start of every `turbo run`. This PR moves it to a background thread so it overlaps with package graph construction, SCM indexing, and other startup work. ## How it works 1. `cli::run` spawns TLS init on `spawn_blocking` immediately — before arg parsing 2. Telemetry uses a new `DeferredTelemetryClient` that resolves the HTTP client lazily on first flush, so telemetry init never blocks 3. `RunBuilder::build()` resolves the HTTP client via a shared `OnceCell` after the package graph and SCM tasks have been running concurrently — by that point, TLS has had the full startup pipeline to complete in the background 4. Analytics startup moved inside `build()` since it needs the resolved API client, so `build()` now returns `(Run, Option<AnalyticsHandle>)` ## Profiling results Measured with `--profile` on three repos of different sizes. The key metric is `resolve_api_client` — how long the main thread blocks waiting for TLS init after all the overlapping work has completed. Lower is better (0ms = fully hidden). | Repo size | `build_http_client` (TLS) | `resolve_api_client` (wait) | Critical path savings | |---|---|---|---| | ~1000 packages | 91ms | 0ms | **91ms** | | ~125 packages | 94ms | 26ms | **68ms** | | ~6 packages | 92ms | 89ms | **3ms** | Savings scale with repo size: larger repos have more `build()` work (package graph construction, lockfile parsing, SCM indexing) running concurrently with TLS init. Small repos see minimal improvement since there's almost nothing to overlap with, but they don't regress — the worst case is parity with the baseline. ## Testing - `cargo check --workspace` clean (zero errors, zero warnings) - `cargo test -p turborepo-api-client --lib` — 18 passed - Verified `--profile` captures `resolve_api_client`, `http_client_init`, and `build_http_client` spans correctly - Verified only one `build_http_client` call occurs (OnceCell deduplication works)
Docs
This project was generated with Angular CLI version 17.3.7.
Development server
Run ng serve for a dev server. Navigate to http://localhost:4200/. The application will automatically reload if you change any of the source files.
Code scaffolding
Run ng generate component component-name to generate a new component. You can also use ng generate directive|pipe|service|class|guard|interface|enum|module.
Build
Run ng build to build the project. The build artifacts will be stored in the dist/ directory.
Running unit tests
Run ng test to execute the unit tests via Karma.
Running end-to-end tests
Run ng e2e to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.
Further help
To get more help on the Angular CLI use ng help or go check out the Angular CLI Overview and Command Reference page.