Skip to content

Commit f60062e

Browse files
authored
Improve CPU resource monitor for Linux systems (#4888)
* 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
1 parent a4c8755 commit f60062e

File tree

4 files changed

+117
-139
lines changed

4 files changed

+117
-139
lines changed

src/Agent.Sdk/Knob/AgentKnobs.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,12 @@ public class AgentKnobs
592592
new EnvironmentKnobSource("AGENT_DISABLE_DRAIN_QUEUES_AFTER_TASK"),
593593
new BuiltInDefaultKnobSource("false"));
594594

595+
public static readonly Knob EnableResourceMonitorDebugOutput = new Knob(
596+
nameof(EnableResourceMonitorDebugOutput),
597+
"If true, the agent will show the resource monitor output for debug runs",
598+
new RuntimeKnobSource("AZP_ENABLE_RESOURCE_MONITOR_DEBUG_OUTPUT"),
599+
new EnvironmentKnobSource("AZP_ENABLE_RESOURCE_MONITOR_DEBUG_OUTPUT"),
600+
new BuiltInDefaultKnobSource("false"));
595601

596602
public static readonly Knob EnableResourceUtilizationWarnings = new Knob(
597603
nameof(EnableResourceUtilizationWarnings),

src/Agent.Worker/JobRunner.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,14 @@ public async Task<TaskResult> RunAsync(Pipelines.AgentJobRequestMessage message,
119119

120120
if (string.Equals(systemDebug, "true", StringComparison.OrdinalIgnoreCase))
121121
{
122-
_ = resourceDiagnosticManager.RunDebugResourceMonitorAsync();
122+
if (AgentKnobs.EnableResourceMonitorDebugOutput.GetValue(jobContext).AsBoolean())
123+
{
124+
_ = resourceDiagnosticManager.RunDebugResourceMonitorAsync();
125+
}
126+
else
127+
{
128+
jobContext.Debug(StringUtil.Loc("ResourceUtilizationDebugOutputIsDisabled"));
129+
}
123130
}
124131

125132
agentShutdownRegistration = HostContext.AgentShutdownToken.Register(() =>

0 commit comments

Comments
 (0)