Skip to content

Commit

Permalink
Improve CPU resource monitor for Linux systems (#4888)
Browse files Browse the repository at this point in the history
* Replace free call on linux

* Minor fixes

* Rework CPU info for linux

* Fix typos

* Fix issue with memory monitor

* Add comments

* Remove task run delegates

* Fix for macos

* Expand comments for metrics methods

* Remove unnecessary cancellation exits

* Add FF to disable resource monitor on debug runs

* Minor fix

* Fix warning

* Replace DisableResourceMonitorDebugOutput with EnableResourceMonitorDebugOutput

* Fix typo

* Update variable name

* Fix typo
  • Loading branch information
vmapetr authored Aug 14, 2024
1 parent a4c8755 commit f60062e
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 139 deletions.
6 changes: 6 additions & 0 deletions src/Agent.Sdk/Knob/AgentKnobs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,12 @@ public class AgentKnobs
new EnvironmentKnobSource("AGENT_DISABLE_DRAIN_QUEUES_AFTER_TASK"),
new BuiltInDefaultKnobSource("false"));

public static readonly Knob EnableResourceMonitorDebugOutput = new Knob(
nameof(EnableResourceMonitorDebugOutput),
"If true, the agent will show the resource monitor output for debug runs",
new RuntimeKnobSource("AZP_ENABLE_RESOURCE_MONITOR_DEBUG_OUTPUT"),
new EnvironmentKnobSource("AZP_ENABLE_RESOURCE_MONITOR_DEBUG_OUTPUT"),
new BuiltInDefaultKnobSource("false"));

public static readonly Knob EnableResourceUtilizationWarnings = new Knob(
nameof(EnableResourceUtilizationWarnings),
Expand Down
9 changes: 8 additions & 1 deletion src/Agent.Worker/JobRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,14 @@ public async Task<TaskResult> RunAsync(Pipelines.AgentJobRequestMessage message,

if (string.Equals(systemDebug, "true", StringComparison.OrdinalIgnoreCase))
{
_ = resourceDiagnosticManager.RunDebugResourceMonitorAsync();
if (AgentKnobs.EnableResourceMonitorDebugOutput.GetValue(jobContext).AsBoolean())
{
_ = resourceDiagnosticManager.RunDebugResourceMonitorAsync();
}
else
{
jobContext.Debug(StringUtil.Loc("ResourceUtilizationDebugOutputIsDisabled"));
}
}

agentShutdownRegistration = HostContext.AgentShutdownToken.Register(() =>
Expand Down
Loading

0 comments on commit f60062e

Please sign in to comment.