Skip to content

[procmgr] Anchor in-flight Stop RPCs to SCM shutdown budget - #55253

Closed
jose-manuel-almaza wants to merge 10 commits into
jose/procmgr-manager-runtimefrom
jose/procmgr-rpc-stop-shutdown-budget
Closed

[procmgr] Anchor in-flight Stop RPCs to SCM shutdown budget#55253
jose-manuel-almaza wants to merge 10 commits into
jose/procmgr-manager-runtimefrom
jose/procmgr-rpc-stop-shutdown-budget

Conversation

@jose-manuel-almaza

@jose-manuel-almaza jose-manuel-almaza commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Anchors in-flight Stop RPC teardown to the Windows SCM shutdown budget so RPC stops cannot outlive the service stop deadline.

Motivation

A large custom stop_timeout or SCM stop mid-RPC could keep the service in STOP_PENDING past the SCM wait hint.

Describe how you validated your changes

  • Unit test test_prefer_service_stop_without_signal_preserves_fallback in shutdown.rs
  • Existing shutdown/process stop tests in CI

@jose-manuel-almaza
jose-manuel-almaza requested a review from a team as a code owner August 21, 2026 16:24
@jose-manuel-almaza jose-manuel-almaza added the changelog/no-changelog No changelog entry needed label Aug 21, 2026
@jose-manuel-almaza jose-manuel-almaza added the qa/done QA done before merge and regressions are covered by tests label Aug 21, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a14f1af9be

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pkg/procmgr/rust/src/shutdown.rs Outdated
Comment thread pkg/procmgr/rust/src/process.rs Outdated
@github-actions github-actions Bot added the short review PR is simple enough to be reviewed quickly label Aug 21, 2026
@datadog-datadog-prod-us1

datadog-datadog-prod-us1 Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 55.07% (+0.00%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: c98e08c | Docs | View more details | Give us feedback!

@jose-manuel-almaza
jose-manuel-almaza requested review from a team as code owners August 24, 2026 05:59
@mrafi97
mrafi97 requested review from clarkb7 and removed request for mrafi97 August 24, 2026 13:31
@aiuto
aiuto removed the request for review from a team August 24, 2026 14:52
@jose-manuel-almaza
jose-manuel-almaza force-pushed the jose/procmgr-rpc-stop-shutdown-budget branch from a14f1af to c87878a Compare August 26, 2026 17:13
@dd-octo-sts

dd-octo-sts Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Files inventory check summary

File checks results against ancestor 02e9fab5:

Results for datadog-agent_7.84.0~devel.git.1075.c98e08c.pipeline.134665832-1_amd64.deb:

No change detected

Results for datadog-iot-agent_7.84.0~devel.git.1075.c98e08c.pipeline.134665832-1_amd64.deb:

No change detected

@cit-pr-commenter-54b7da

cit-pr-commenter-54b7da Bot commented Aug 26, 2026

Copy link
Copy Markdown

Regression Detector

Regression Detector Results

Metrics dashboard
Target profiles
Job ID: 9b6a9c81-f4bd-44b6-9791-5b2dcffb7224

Baseline: 02e9fab
Comparison: c98e08c
Diff

Optimization Goals: ✅ No significant changes detected

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI trials links
quality_gate_logs % cpu utilization +2.05 [+1.16, +2.95] 1 Logs bounds checks dashboard
quality_gate_metrics_logs memory utilization +1.44 [+1.21, +1.67] 1 Logs bounds checks dashboard
dsd_uds_10mb_3k_timestamped_contexts_cpu % cpu utilization +0.88 [+0.64, +1.13] 1 Logs
dsd_uds_10mb_3k_timestamped_contexts_memory memory utilization +0.52 [+0.31, +0.74] 1 Logs
quality_gate_security_mean_fs_load memory utilization +0.40 [+0.37, +0.44] 1 Logs bounds checks dashboard
quality_gate_idle_all_features memory utilization +0.06 [+0.03, +0.10] 1 Logs bounds checks dashboard
quality_gate_security_idle memory utilization +0.02 [-0.02, +0.07] 1 Logs bounds checks dashboard
quality_gate_security_no_fs_load memory utilization -0.05 [-0.14, +0.03] 1 Logs bounds checks dashboard
quality_gate_private_action_runner memory utilization -0.10 [-0.22, +0.03] 1 Logs bounds checks dashboard
quality_gate_idle memory utilization -0.21 [-0.25, -0.17] 1 Logs bounds checks dashboard

Bounds Checks: ✅ Passed

perf experiment bounds_check_name replicates_passed observed_value links
quality_gate_idle intake_connections 10/10 4 = 4 bounds checks dashboard
quality_gate_idle memory_usage 10/10 175.41MiB ≤ 179MiB bounds checks dashboard
quality_gate_idle total_bytes_received 10/10 750.09KiB ≤ 819.20KiB bounds checks dashboard
quality_gate_idle_all_features intake_connections 10/10 4 = 4 bounds checks dashboard
quality_gate_idle_all_features memory_usage 10/10 520.66MiB ≤ 537MiB bounds checks dashboard
quality_gate_idle_all_features total_bytes_received 10/10 1.14MiB ≤ 1.25MiB bounds checks dashboard
quality_gate_logs intake_connections 10/10 18 ≤ 40 bounds checks dashboard
quality_gate_logs memory_usage 10/10 218.95MiB ≤ 228MiB bounds checks dashboard
quality_gate_logs missed_bytes 10/10 0B = 0B bounds checks dashboard
quality_gate_logs total_bytes_received 10/10 263.67MiB ≤ 292MiB bounds checks dashboard
quality_gate_metrics_logs cpu_usage 10/10 366.20 ≤ 2000 bounds checks dashboard
quality_gate_metrics_logs intake_connections 10/10 20 ≤ 40 bounds checks dashboard
quality_gate_metrics_logs memory_usage 10/10 426.56MiB ≤ 455MiB bounds checks dashboard
quality_gate_metrics_logs missed_bytes 10/10 0B = 0B bounds checks dashboard
quality_gate_metrics_logs total_bytes_received 10/10 0.94GiB ≤ 1.04GiB bounds checks dashboard
quality_gate_private_action_runner memory_usage 10/10 71.45MiB ≤ 75MiB bounds checks dashboard
quality_gate_security_idle cpu_usage 10/10 27.99 ≤ 100 bounds checks dashboard
quality_gate_security_idle memory_usage 10/10 324.39MiB ≤ 355MiB bounds checks dashboard
quality_gate_security_mean_fs_load cpu_usage 10/10 60.60 ≤ 200 bounds checks dashboard
quality_gate_security_mean_fs_load memory_usage 10/10 307.75MiB ≤ 335MiB bounds checks dashboard
quality_gate_security_no_fs_load cpu_usage 10/10 23.23 ≤ 100 bounds checks dashboard
quality_gate_security_no_fs_load memory_usage 10/10 312.28MiB ≤ 345MiB bounds checks dashboard

Explanation

Confidence level: 90.00%
Effect size tolerance: |Δ mean %| ≥ 5.00%

Performance changes are noted in the perf column of each table:

  • ✅ = significantly better comparison variant performance
  • ❌ = significantly worse comparison variant performance
  • ➖ = no significant change in performance

A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".

For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:

  1. Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.

  2. Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.

  3. Its configuration does not mark it "erratic".

CI Pass/Fail Decision

Passed. All Quality Gates passed.

  • quality_gate_logs, bounds check missed_bytes: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_security_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_idle, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_mean_fs_load, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_mean_fs_load, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check missed_bytes: 10/10 replicas passed. Gate passed.
  • quality_gate_metrics_logs, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_idle_all_features, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check intake_connections: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check total_bytes_received: 10/10 replicas passed. Gate passed.
  • quality_gate_idle, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_no_fs_load, bounds check memory_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_security_no_fs_load, bounds check cpu_usage: 10/10 replicas passed. Gate passed.
  • quality_gate_private_action_runner, bounds check memory_usage: 10/10 replicas passed. Gate passed.

@jose-manuel-almaza
jose-manuel-almaza force-pushed the jose/procmgr-rpc-stop-shutdown-budget branch from c0d6f41 to 809f540 Compare August 27, 2026 11:34
@jose-manuel-almaza
jose-manuel-almaza changed the base branch from jose/procmgr-spawn-profiles to jose/procmgr-manager-runtime August 27, 2026 11:44
@jose-manuel-almaza
jose-manuel-almaza force-pushed the jose/procmgr-rpc-stop-shutdown-budget branch from 809f540 to 69ccefb Compare August 27, 2026 13:21
@jose-manuel-almaza jose-manuel-almaza changed the title fix(procmgr): anchor in-flight Stop RPCs to SCM shutdown budget [procmgr] Anchor in-flight Stop RPCs to SCM shutdown budget Aug 28, 2026
@jose-manuel-almaza
jose-manuel-almaza force-pushed the jose/procmgr-rpc-stop-shutdown-budget branch from a67a4de to 7594a58 Compare August 28, 2026 07:23
@jose-manuel-almaza

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d170acb45e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pkg/procmgr/rust/src/shutdown.rs Outdated
Comment thread pkg/procmgr/rust/src/shutdown.rs Outdated
@jose-manuel-almaza

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 68291d622e

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pkg/procmgr/rust/src/platform/windows/scm_service.rs
@jose-manuel-almaza

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f53dd0f10d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pkg/procmgr/rust/src/platform/windows/mod.rs
@jose-manuel-almaza

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: d9c2449055

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@jose-manuel-almaza

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: cf71a8621f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@jose-manuel-almaza

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b724457be3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pkg/procmgr/rust/src/shutdown.rs
@jose-manuel-almaza

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

Reviewed commit: b724457be3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@jose-manuel-almaza

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 7bb6993a08

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@dd-octo-sts

dd-octo-sts Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Static quality checks

✅ Please find below the results from static quality gates
Comparison made with ancestor 02e9fab
📊 Static Quality Gates Dashboard
🔗 SQG Job

Successful checks

Info

Quality gate Change Size (prev → curr → max)
agent_deb_amd64 +116.11 KiB (0.01% increase, -5.14% of buffer) 763.496 → 763.609 → 765.700
agent_deb_amd64_fips +116.11 KiB (0.02% increase, -9.45% of buffer) 715.780 → 715.894 → 716.980
agent_msi +135.36 KiB (0.02% increase, -1.05% of buffer) 649.829 → 649.962 → 662.360
agent_rpm_amd64 +116.11 KiB (0.01% increase, -5.18% of buffer) 763.480 → 763.593 → 765.670
agent_rpm_amd64_fips +116.11 KiB (0.02% increase, -9.32% of buffer) 715.764 → 715.877 → 716.980
agent_rpm_arm64 +100.11 KiB (0.01% increase, -13.65% of buffer) 739.294 → 739.391 → 740.010
agent_rpm_arm64_fips +104.11 KiB (0.01% increase, -10.63% of buffer) 694.924 → 695.025 → 695.880
agent_suse_amd64 +116.11 KiB (0.01% increase, -5.18% of buffer) 763.480 → 763.593 → 765.670
agent_suse_amd64_fips +116.11 KiB (0.02% increase, -9.32% of buffer) 715.764 → 715.877 → 716.980
agent_suse_arm64 +100.11 KiB (0.01% increase, -13.65% of buffer) 739.294 → 739.391 → 740.010
agent_suse_arm64_fips +104.11 KiB (0.01% increase, -10.63% of buffer) 694.924 → 695.025 → 695.880
docker_agent_amd64 +116.1 KiB (0.01% increase, -25.40% of buffer) 822.454 → 822.567 → 822.900
docker_agent_arm64 +100.11 KiB (0.01% increase, -12.85% of buffer) 823.320 → 823.417 → 824.080
docker_agent_jmx_amd64 +116.11 KiB (0.01% increase, -15.24% of buffer) 1013.366 → 1013.479 → 1014.110
docker_agent_jmx_arm64 +100.11 KiB (0.01% increase, -12.89% of buffer) 1003.012 → 1003.109 → 1003.770
18 successful checks with minimal change (< 2 KiB)
Quality gate Current Size
agent_heroku_amd64 316.901 MiB
docker_cluster_agent_amd64 212.614 MiB
docker_cluster_agent_arm64 225.716 MiB
docker_cws_instrumentation_amd64 7.439 MiB
docker_cws_instrumentation_arm64 6.877 MiB
docker_dogstatsd_amd64 39.553 MiB
docker_dogstatsd_arm64 37.623 MiB
docker_host_profiler_amd64 308.709 MiB
docker_host_profiler_arm64 319.936 MiB
dogstatsd_deb_amd64 30.294 MiB
dogstatsd_deb_arm64 28.306 MiB
dogstatsd_rpm_amd64 30.294 MiB
dogstatsd_suse_amd64 30.294 MiB
iot_agent_deb_amd64 46.584 MiB
iot_agent_deb_arm64 43.217 MiB
iot_agent_deb_armhf 44.031 MiB
iot_agent_rpm_amd64 46.584 MiB
iot_agent_suse_amd64 46.583 MiB

RPC stops used an unlimited ShutdownBudget while the supervisor loop was
blocked, so a large stop_timeout could exceed the Windows service deadline.
Apply the SCM-anchored budget when a stop signal is recorded and interrupt
graceful waits on shutdown_notify.
Rebase onto spawn-profiles shutdown latch. Wake all shutdown waiters on
SCM stop, route graceful stop through wait_for_shutdown/shutdown_requested,
refresh the SCM budget before Windows resource cleanup, and share the
service-stop cap helper with auto-start join.
Call runtime.shutdown_timeout with the remaining service stop budget
after supervisor exit so stuck spawn_blocking auto-start work cannot
block reporting SERVICE_STOPPED past the SCM wait hint.
Ordered shutdown already sets shutdown_requested, so an immediate zero timeout skipped every child's configured graceful interval.
Register the waiter first so a missed notify_waiters still caps an in-flight Stop to the remaining SCM budget instead of the original stop_timeout.
SCM can record shutdown before startup polls shutdown_signal, so a lost notify left the service in STOP_PENDING. Return immediately when the flag is already set and begin stopping on empty-catalog startup.
wait_for_shutdown now pins and enables the notify waiter before
rechecking shutdown_requested, closing the check-to-subscribe race
that could leave shutdown blocked after an early SCM stop.
Gate for_single_stop to Windows, re-export deferred spawn cleanup from
manager, and align startup SCM budget check with the base formatting.
The join_deferred_spawn_tasks re-export is only used from scm_service,
so exporting it on Linux triggers Clippy unused-import failures.
Route StopWaitPlan graceful waits through wait_graceful_or_shutdown,
anchor handle_stop to for_single_stop(), and refresh the SCM budget
between graceful and force-kill phases so in-flight Stop RPCs cut short
on service shutdown.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants