Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: CPU/Network usage displayed are not accurate (they are cumulative measures instead of current measures) #156

Closed
nvnikolov opened this issue Jun 5, 2024 · 1 comment · Fixed by #158
Assignees
Labels
bug Something isn't working

Comments

@nvnikolov
Copy link
Contributor

Contact details

No response

Current behavior

Display is cumulative data

Expected behavior

Should be current data

Steps to reproduce

Run any pipeline

Environment

  • SIM-PIPE version: 0.4.0
  • Platform/OS: n/a
  • Browser: n/a
  • Other:

Screenshots

No response

Logs

No response

@nvnikolov nvnikolov added the bug Something isn't working label Jun 5, 2024
@nvnikolov
Copy link
Contributor Author

Some code for fixing (in resource-utils.ts in frontend):
export async function getMetricsUsageUtils(metrics: DryRunMetrics[]): Promise<{
allStepNames: string[];
cumulativeCPUData: any;
currentCPUUsageData: any;
memoryData: any;
networkDataCombined: any;
logs: { [x: string]: string };
}> {
const allStepNames: string[] = [];
const cpuConsumptionData: { [key: string]: MetricsWithTimeStamps } = {};
const cpuData: { [key: string]: MetricsWithTimeStamps } = {};
const memoryData: { [key: string]: MetricsWithTimeStamps } = {};
const networkDataCombined: {
[key: string]: MetricsWithTimeStamps[];
} = {};
const logs: { [x: string]: string } = {};
metrics
?.filter((metric) => metric.type === 'Pod')
.forEach((node: DryRunMetrics) => {
if (Object.keys(node).length > 0) {
// HOTFIX (a.k.a. hack) to display absolute CPU usage instead of cumulative usage in seconds
let previousValue = 0;
let cpuConsumption = {};
node.metrics.cpuUsageSecondsTotal.forEach((cpuUsageEntry) => {
const updatedEntry = { ...cpuUsageEntry };
updatedEntry.value -= previousValue;
if (updatedEntry.value) {
previousValue = updatedEntry.value;
cpuConsumption = { ...updatedEntry };
}
});
cpuConsumptionData[node.displayName] = changeResourceFormat(
node.startedAt,
cpuConsumption,
node.displayName,
'cpu'
);

			cpuData[node.displayName] = changeResourceFormat(
				node.startedAt,
				node.metrics.cpuUsageSecondsTotal,
				node.displayName,
				'cpu'
			);
			memoryData[node.displayName] = changeResourceFormat(
				node.startedAt,
				node.metrics.memoryUsageBytes,
				node.displayName
			);
			if (!networkDataCombined[node.displayName]) networkDataCombined[node.displayName] = [];
			networkDataCombined[node.displayName].push(
				changeResourceFormat(
					node.startedAt,
					node.metrics.networkReceiveBytesTotal,
					node.displayName,
					'Received'
				),
				changeResourceFormat(
					node.startedAt,
					node.metrics.networkTransmitBytesTotal,
					node.displayName,
					'Transmitted'
				)
			);
		}
	});

return { allStepNames, currentCPUUsageData: cpuConsumptionData, cumulativeCPUData: cpuData, memoryData, networkDataCombined, logs };

}

@goranbs goranbs self-assigned this Jun 5, 2024
@goranbs goranbs mentioned this issue Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants