Skip to content

feat(hotpath): fill usecases stream/emit/semantic-config gaps - #785

Draft
ScriptedAlchemy wants to merge 4 commits into
codex/tracedecay-total-redesign-plan-reopenedfrom
cursor/hotpath-gap-fill-2db4
Draft

feat(hotpath): fill usecases stream/emit/semantic-config gaps#785
ScriptedAlchemy wants to merge 4 commits into
codex/tracedecay-total-redesign-plan-reopenedfrom
cursor/hotpath-gap-fill-2db4

Conversation

@ScriptedAlchemy

Copy link
Copy Markdown
Owner

Summary

  • Gap-fill hotpath instrumentation PR scoped to crates/tracedecay-usecases only (HP-usecases). Adds 111 new measure sites (102 #[hotpath::measure] attributes, 9 hotpath::future! wraps of boxed port futures) across 14 files.
  • Targets the previously uninstrumented hot files (operation_stream.rs, observability emit/producer lanes, semantic config store/operation, diagnostics publication, vector generation store, advisory GitHub/CI stores) plus add-missing-only sites in semantic_runtime/production.rs, diagnostics_store.rs, and feedback/concrete.rs.
  • No existing measure sites were touched, no Cargo.toml changes, no feature wiring changes. Macros no-op without --features hotpath; the feature stays out of default/production. The hook-protocol metrics-server guard is untouched. Does not merge feat: consolidate TraceDecay V2 PR8-PR13 delivery #707.

Motivation

Coverage inventory showed 68/340 async fns measured and ~84 files with no hotpath sites in tracedecay-usecases. This fills the highest-value gaps (usecase entrypoints, durable store read/write paths, emit lanes) so opt-in profiling sees the full request path.

Changes

File New sites New labels
src/operation_stream.rs 12 usecases.operation.{begin, begin_test_run, cancel, cancel_test_run, subscribe, expire_all, resolve_context, read_test_run, page_test_run, emit_progress, emit_test_result, emit_terminal}
src/observability/retrieval_emit.rs 9 usecases.observability.{emit_pipeline, observe_ablation, record_planner, record_retriever, record_synthesis, record_source, record_context_outcome, record_ablation, record_consent}
src/observability/emit.rs 8 usecases.observability.{record_query, record_adoption_eligibility, record_adoption_outcome, record_latency, record_operation_resource, record_storage, record_index, emit_index}
src/observability/producer.rs 4 usecases.observability.{try_emit, producer_stop, persist_queued, persist_envelope}
src/semantic_runtime/config_store.rs 9 usecases.semantic_config.{install_initial, read_committed, read_present, read_profile, read_committed_profile, preview_mutation, stage_activation, stage_rollback, persist_pending}
src/semantic_runtime/configuration_operation.rs 8 usecases.semantic_config.{commit_publication, qualify_profile, evaluate_publish, activate, rollback, prepare_activation, validate_snapshot, read_state}
src/diagnostics_publication.rs 6 usecases.diagnostics.{contribute, publish_snapshot, resolve_compiler, load_project_file, publish_compiler, publish_compiler_indexed}
src/store/vector_generations.rs 11 usecases.vector.{begin_generation, rebuild_generation, commit_batch, validate_batch, apply_batch, publish_generation, persist_sealed, reopen_sealed, intern_vectors, hydrate_values, sweep_retired}
src/advisory/github_runtime/store.rs 5 usecases.advisory.github.{load_manifest, load_inventory, load_entry, load_state, record_refresh}
src/advisory/github_runtime/anchors.rs 9 usecases.advisory.github.{resolve_seeds, resolve_stored_seed, resolve_new_seed, remap_original, remap_seed, load_anchor, persist_anchor, persist_body, read_body}
src/advisory/ci_runtime/stores.rs 6 usecases.advisory.ci.{load_inventory, load_entry, load_manifest, load_record, retain_observation, resolve_code_anchor}
src/semantic_runtime/production.rs 6 usecases.semantic.{restore_current, prepare_restore, revalidate_target, active_generation, execute_search, inspect_eval_snapshot}
src/diagnostics_store.rs 6 usecases.diagnostics_store.{immediate_tx, insert_record, publication_state, query_generation, find_successor, collect_rows}
src/feedback/concrete.rs 12 usecases.feedback.{read_diagnostics, read_get, read_expand, read_list, close_drain, load_publications, doctor_latest, record_publication, observation_read_model, persist_observation, persist_boot, load_ledger}

Non-obvious bits:

  • Port-trait methods returning FeedbackPortFuture<'a, _> (boxed futures) cannot take the attribute macro, so they are wrapped as Box::pin(hotpath::future!(async move { ... }, label = "...")), the same pattern already used in feedback/cycle_production.rs and feedback/cycle_runtime.rs.
  • commit_batch is measured on commit_batch_ref (the shared implementation) so the public wrapper and the persistent adapter path are both covered by one span without double counting.
  • All 111 labels are unique and verified against the existing tree (no collisions with pre-existing labels). Skipped: getters, Display impls, serde/DTO glue, test modules, and long-lived worker loops (run_worker/settle_worker — per-iteration persistence is measured instead).
  • hotpath::future! is used without any hotpath/tokio passthrough, matching existing usage in this crate; no tokio_runtime! was introduced.

Test plan

  • cargo check -p tracedecay-usecases (default features) passes
  • cargo check -p tracedecay-usecases --features tracedecay-usecases/hotpath passes
  • cargo clippy -p tracedecay-usecases --all-targets --features tracedecay-usecases/hotpath exits 0 (single pre-existing manual_ok_err warning in benches/semantic_vector_commit_scale.rs, untouched by this PR)
  • cargo nextest run --workspace --no-fail-fast (not run here; instrumentation is behavior-neutral without the feature)

Checklist

  • No secrets, credentials, or .env files included
  • Breaking changes documented (none — macros no-op without the opt-in feature)
  • CHANGELOG.md updated (not updated: instrumentation-only change with no user-facing behavior; can add on request)
Open in Web Open in Cursor 

Co-authored-by: Zack Jackson <ScriptedAlchemy@users.noreply.github.com>
@changeset-bot

changeset-bot Bot commented Aug 31, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 25f3806

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Performance Comparison codex/tracedecay-total-redesign-plan-reopenedcursor/hotpath-gap-fill-2db4

Total Elapsed Time: 5.36s → 5.14s (-4.1%)
CPU Baseline: 89.75µs → 89.95µs (+0.2%)
Benchmark ID: index-bench-timing

timing - Execution duration of functions.

+------------------------------------------+----------------------------+---------------------------------+----------------------------------+----------------------------------+------------------------------+
| Function                                 | Calls                      | Avg                             | P95                              | Total                            | % Total                      |
+------------------------------------------+----------------------------+---------------------------------+----------------------------------+----------------------------------+------------------------------+
| tracedecay-index-bench                   | 1 → 1 (+0.0%)              | 5.36s → 5.14s (-4.1%)           | 5.36s → 5.14s (-4.1%)            | 5.36s → 5.14s (-4.1%)            | 100.00% → 100.00% (+0.0%)    |
+------------------------------------------+----------------------------+---------------------------------+----------------------------------+----------------------------------+------------------------------+
| query.artifact.append_pages              | 13 → 13 (+0.0%)            | 180.47ms → 184.35ms (+2.1%)     | 242.88ms → 266.60ms (+9.8%)      | 2.35s → 2.40s (+2.1%)            | 43.79% → 46.63% (+6.5%)      |
+------------------------------------------+----------------------------+---------------------------------+----------------------------------+----------------------------------+------------------------------+
| query.artifact.batch.sqlite              | 13 → 13 (+0.0%)            | 122.39ms → 122.32ms (-0.1%)     | 167.12ms → 172.49ms (+3.2%)      | 1.59s → 1.59s (+0.0%)            | 29.70% → 30.94% (+4.2%)      |
+------------------------------------------+----------------------------+---------------------------------+----------------------------------+----------------------------------+------------------------------+
| query.artifact.batch.postings            | 13 → 13 (+0.0%)            | 107.57ms → 106.84ms (-0.7%)     | 147.98ms → 147.72ms (-0.2%)      | 1.40s → 1.39s (-0.7%)            | 26.10% → 27.02% (+3.5%)      |
+------------------------------------------+----------------------------+---------------------------------+----------------------------------+----------------------------------+------------------------------+
| code_index.workers.install               | 83 → 83 (+0.0%)            | 18.75ms → 16.02ms (-14.6%)      | 52.46ms → 57.51ms (+9.6%)        | 1.56s → 1.33s (-14.7%)           | 29.04% → 25.88% (-10.9%)     |
+------------------------------------------+----------------------------+---------------------------------+----------------------------------+----------------------------------+------------------------------+
| CodeIndexProductionOwnerV1::extract_file | 276 → 276 (+0.0%)          | 5.92ms → 4.51ms (-23.8%) 🚀     | 12.98ms → 6.75ms (-48.0%) 🚀     | 1.63s → 1.24s (-23.9%) 🚀        | 30.47% → 24.21% (-20.5%) 🚀  |
+------------------------------------------+----------------------------+---------------------------------+----------------------------------+----------------------------------+------------------------------+
| code_index.build.and_publish             | 2 → 2 (+0.0%)              | 613.74ms → 505.51ms (-17.6%)    | 643.83ms → 507.77ms (-21.1%) 🚀  | 1.23s → 1.01s (-17.9%)           | 22.91% → 19.67% (-14.1%)     |
+------------------------------------------+----------------------------+---------------------------------+----------------------------------+----------------------------------+------------------------------+
| domain.canonical.sha256                  | 114526 → 114526 (+0.0%)    | 10.87µs → 8.48µs (-22.0%) 🚀    | 14.09µs → 13.91µs (-1.3%)        | 1.24s → 970.95ms (-21.7%) 🚀     | 23.23% → 18.89% (-18.7%)     |
+------------------------------------------+----------------------------+---------------------------------+----------------------------------+----------------------------------+------------------------------+
| query.artifact.finalization.advance_wake | 14 → 14 (+0.0%)            | 52.56ms → 55.57ms (+5.7%)       | 261.75ms → 282.33ms (+7.9%)      | 735.83ms → 778.01ms (+5.7%)      | 13.73% → 15.14% (+10.3%)     |
+------------------------------------------+----------------------------+---------------------------------+----------------------------------+----------------------------------+------------------------------+
| query.artifact.prepare_pages             | 13 → 13 (+0.0%)            | 48.48ms → 52.41ms (+8.1%)       | 66.78ms → 81.72ms (+22.4%) ⚠️    | 630.21ms → 681.38ms (+8.1%)      | 11.76% → 13.26% (+12.8%)     |
+------------------------------------------+----------------------------+---------------------------------+----------------------------------+----------------------------------+------------------------------+
| code_index.chunk.index_file              | 276 → 276 (+0.0%)          | 2.67ms → 2.08ms (-22.1%) 🚀     | 5.91ms → 3.09ms (-47.7%) 🚀      | 736.45ms → 573.97ms (-22.1%) 🚀  | 13.74% → 11.17% (-18.7%)     |
+------------------------------------------+----------------------------+---------------------------------+----------------------------------+----------------------------------+------------------------------+
| query.artifact.batch.parallel_prepare    | 13 → 13 (+0.0%)            | 38.16ms → 42.07ms (+10.2%)      | 52.46ms → 68.42ms (+30.4%) ⚠️    | 496.04ms → 546.89ms (+10.3%)     | 9.26% → 10.64% (+14.9%)      |
+------------------------------------------+----------------------------+---------------------------------+----------------------------------+----------------------------------+------------------------------+
| code_index.extract.parser_artifact       | 276 → 276 (+0.0%)          | 2.41ms → 1.90ms (-21.2%) 🚀     | 5.81ms → 2.83ms (-51.3%) 🚀      | 663.87ms → 523.23ms (-21.2%) 🚀  | 12.39% → 10.18% (-17.8%)     |
+------------------------------------------+----------------------------+---------------------------------+----------------------------------+----------------------------------+------------------------------+
| 🆕 code_index.build.assemble             | 0 → 2 (+100.0%) ⚠️         | 0.00ns → 187.76ms (+100.0%) ⚠️  | 0.00ns → 200.54ms (+100.0%) ⚠️   | 0.00ns → 375.52ms (+100.0%) ⚠️   | 0.00% → 7.31% (+100.0%) ⚠️   |
+------------------------------------------+----------------------------+---------------------------------+----------------------------------+----------------------------------+------------------------------+
| code_index.chunk.build                   | 276 → 276 (+0.0%)          | 1.59ms → 1.26ms (-20.8%) 🚀     | 4.34ms → 1.82ms (-58.1%) 🚀      | 438.89ms → 348.69ms (-20.6%) 🚀  | 8.19% → 6.78% (-17.2%)       |
+------------------------------------------+----------------------------+---------------------------------+----------------------------------+----------------------------------+------------------------------+
| 🗑️ code_index.build.materialize_full     | 1 → 0 (-100.0%) 🚀         | 438.32ms → 0.00ns (-100.0%) 🚀  | 438.57ms → 0.00ns (-100.0%) 🚀   | 438.32ms → 0.00ns (-100.0%) 🚀   | 8.18% → 0.00% (-100.0%) 🚀   |
+------------------------------------------+----------------------------+---------------------------------+----------------------------------+----------------------------------+------------------------------+

Generated with hotpath-rs

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.

2 participants