Skip to content

Commit

Permalink
[8.15] [Profiling] Fix TopN function total CPU value (#188848) (#188974)
Browse files Browse the repository at this point in the history
# Backport

This will backport the following commits from `main` to `8.15`:
- [[Profiling] Fix TopN function total CPU value
(#188848)](#188848)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Cauê
Marcondes","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-07-23T15:21:08Z","message":"[Profiling]
Fix TopN function total CPU value (#188848)\n\ncloses
https://github.com/elastic/kibana/issues/188511\r\n\r\n<img
width=\"2784\" alt=\"Screenshot 2024-07-22 at 13 59
28\"\r\nsrc=\"https://github.com/user-attachments/assets/910ae596-ef22-4c18-b31f-7a9016e3b61d\">\r\n<img
width=\"2756\" alt=\"Screenshot 2024-07-22 at 14 55
50\"\r\nsrc=\"https://github.com/user-attachments/assets/66be5e9f-0d55-4b02-b97a-1425b6f0420c\">\r\n15","sha":"2ced9416d3b87ffbe247974724420e357d667035","branchLabelMapping":{"^v8.16.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","ci:project-deploy-observability","v8.15.0","v8.16.0"],"title":"[Profiling]
Fix TopN function total CPU
value","number":188848,"url":"https://github.com/elastic/kibana/pull/188848","mergeCommit":{"message":"[Profiling]
Fix TopN function total CPU value (#188848)\n\ncloses
https://github.com/elastic/kibana/issues/188511\r\n\r\n<img
width=\"2784\" alt=\"Screenshot 2024-07-22 at 13 59
28\"\r\nsrc=\"https://github.com/user-attachments/assets/910ae596-ef22-4c18-b31f-7a9016e3b61d\">\r\n<img
width=\"2756\" alt=\"Screenshot 2024-07-22 at 14 55
50\"\r\nsrc=\"https://github.com/user-attachments/assets/66be5e9f-0d55-4b02-b97a-1425b6f0420c\">\r\n15","sha":"2ced9416d3b87ffbe247974724420e357d667035"}},"sourceBranch":"main","suggestedTargetBranches":["8.15"],"targetPullRequestStates":[{"branch":"8.15","label":"v8.15.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/188848","number":188848,"mergeCommit":{"message":"[Profiling]
Fix TopN function total CPU value (#188848)\n\ncloses
https://github.com/elastic/kibana/issues/188511\r\n\r\n<img
width=\"2784\" alt=\"Screenshot 2024-07-22 at 13 59
28\"\r\nsrc=\"https://github.com/user-attachments/assets/910ae596-ef22-4c18-b31f-7a9016e3b61d\">\r\n<img
width=\"2756\" alt=\"Screenshot 2024-07-22 at 14 55
50\"\r\nsrc=\"https://github.com/user-attachments/assets/66be5e9f-0d55-4b02-b97a-1425b6f0420c\">\r\n15","sha":"2ced9416d3b87ffbe247974724420e357d667035"}}]}]
BACKPORT-->

Co-authored-by: Cauê Marcondes <[email protected]>
  • Loading branch information
kibanamachine and cauemarcondes authored Jul 23, 2024
1 parent 307143b commit 8730a13
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ describe('Functions page', () => {
const firstRowSelector = '[data-grid-row-index="0"] [data-test-subj="dataGridRowCell"]';
cy.get(firstRowSelector).eq(1).contains('1');
cy.get(firstRowSelector).eq(2).contains('vmlinux');
cy.get(firstRowSelector).eq(3).contains('0.16%');
cy.get(firstRowSelector).eq(4).contains('0.16%');
cy.get(firstRowSelector).eq(3).contains('5.46%');
cy.get(firstRowSelector).eq(4).contains('5.46%');
cy.get(firstRowSelector).eq(5).contains('3.97 lbs / 1.8 kg');
cy.get(firstRowSelector).eq(6).contains('$17.37');
cy.get(firstRowSelector).eq(7).contains('28');
Expand All @@ -56,8 +56,8 @@ describe('Functions page', () => {
{ parentKey: 'informationRows', key: 'executable', value: 'vmlinux' },
{ parentKey: 'informationRows', key: 'function', value: 'N/A' },
{ parentKey: 'informationRows', key: 'sourceFile', value: 'N/A' },
{ parentKey: 'impactEstimates', key: 'totalCPU', value: '0.16%' },
{ parentKey: 'impactEstimates', key: 'selfCPU', value: '0.16%' },
{ parentKey: 'impactEstimates', key: 'totalCPU', value: '5.46%' },
{ parentKey: 'impactEstimates', key: 'selfCPU', value: '5.46%' },
{ parentKey: 'impactEstimates', key: 'samples', value: '28' },
{ parentKey: 'impactEstimates', key: 'selfSamples', value: '28' },
{ parentKey: 'impactEstimates', key: 'coreSeconds', value: '1.4 seconds' },
Expand Down Expand Up @@ -118,16 +118,16 @@ describe('Functions page', () => {
columnIndex: 3,
highRank: 1,
lowRank: 389,
highValue: '0.16%',
highValue: '5.46%',
lowValue: '0.00%',
},
{
columnKey: 'totalCPU',
columnIndex: 4,
highRank: 693,
lowRank: 44,
highValue: '1.80%',
lowValue: '0.01%',
highValue: '60.43%',
lowValue: '0.19%',
},
{
columnKey: 'annualizedCo2',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('Top N functions: Utils', () => {
expect(getTotalCount()).toEqual(0);
});
it('returns value from topNFunctions', () => {
expect(getTotalCount({ TotalCount: 10 } as TopNFunctions)).toEqual(10);
expect(getTotalCount({ selfCPU: 10 } as TopNFunctions)).toEqual(10);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function scaleValue({ value, scaleFactor = 1 }: { value: number; scaleFac
return value * scaleFactor;
}

export const getTotalCount = (topNFunctions?: TopNFunctions) => topNFunctions?.TotalCount ?? 0;
export const getTotalCount = (topNFunctions?: TopNFunctions) => topNFunctions?.selfCPU ?? 0;

export interface IFunctionRow {
id: string;
Expand Down Expand Up @@ -95,15 +95,15 @@ export function getFunctionsRows({
scaleFactor: baselineScaleFactor,
});

const totalCPUPerc = (topN.CountInclusive / topNFunctions.TotalCount) * 100;
const selfCPUPerc = (topN.CountExclusive / topNFunctions.TotalCount) * 100;
const totalCPUPerc = (topN.CountInclusive / topNFunctions.selfCPU) * 100;
const selfCPUPerc = (topN.CountExclusive / topNFunctions.selfCPU) * 100;

const impactEstimates =
totalSeconds > 0
? calculateImpactEstimates({
countExclusive: topN.CountExclusive,
countInclusive: topN.CountInclusive,
totalSamples: topNFunctions.TotalCount,
totalSamples: topNFunctions.selfCPU,
totalSeconds,
})
: undefined;
Expand All @@ -124,10 +124,9 @@ export function getFunctionsRows({
selfCPU: comparisonRow.CountExclusive,
totalCPU: comparisonRow.CountInclusive,
selfCPUPerc:
selfCPUPerc - (comparisonRow.CountExclusive / comparisonTopNFunctions.TotalCount) * 100,
selfCPUPerc - (comparisonRow.CountExclusive / comparisonTopNFunctions.selfCPU) * 100,
totalCPUPerc:
totalCPUPerc -
(comparisonRow.CountInclusive / comparisonTopNFunctions.TotalCount) * 100,
totalCPUPerc - (comparisonRow.CountInclusive / comparisonTopNFunctions.selfCPU) * 100,
selfAnnualCO2kgs: comparisonRow.selfAnnualCO2kgs,
selfAnnualCostUSD: comparisonRow.selfAnnualCostUSD,
totalAnnualCO2kgs: comparisonRow.totalAnnualCO2kgs,
Expand Down

0 comments on commit 8730a13

Please sign in to comment.