Skip to content

Commit

Permalink
[SearchProfiler] Remove sources of recursion over potentially deeply …
Browse files Browse the repository at this point in the history
…nested objects (#54015)

* Added max tree depth guard
Removed recursive normalizeTimes functions (one fewer iteration through the entire data structure)
Optimizied appliation of tree mutations by taking `if` out of tight loop
Cleaned up types

* Tidy up data being passed into store (and through immer)

* Fix max tree depth logic

* Remove immer from non-test code.

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
jloleysens and elasticmachine authored Jan 10, 2020
1 parent 599af6a commit 753eb53
Show file tree
Hide file tree
Showing 17 changed files with 947 additions and 747 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,8 @@ describe('Highlight Details Flyout', () => {
it('renders', async () => {
const props: Props = {
onClose: () => {},
shard: {
aggregations: [],
id: ['test', 'test', 'test'],
searches: [],
color: '#fff',
time: 123,
relative: 100,
},
shardName: '[test][test]',
operation: {
parent: null,
breakdown: [
{
color: 'test',
Expand Down Expand Up @@ -48,8 +40,7 @@ describe('Highlight Details Flyout', () => {
query_type: 'test',
selfTime: 100,
time: 100,
children: [],
timePercentage: 100,
timePercentage: '100',
hasChildren: false,
visible: true,
absoluteColor: '123',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import {

import { msToPretty } from '../../utils';
import { HighlightDetailsTable } from './highlight_details_table';
import { Operation, Shard } from '../../types';
import { Operation } from '../../types';

export interface Props {
operation: Operation;
shard: Shard;
operation: Omit<Operation, 'children' | 'parent'>;
shardName: string;
indexName: string;
onClose: () => void;
}
Expand All @@ -39,14 +39,12 @@ const FlyoutEntry = ({
</>
);

export const HighlightDetailsFlyout = ({ indexName, operation, shard, onClose }: Props) => {
export const HighlightDetailsFlyout = ({ indexName, operation, shardName, onClose }: Props) => {
return (
<EuiFlyout className="prfDevTool__details" onClose={() => onClose()}>
<EuiFlyoutHeader hasBorder={true}>
<EuiText size="s">{indexName}</EuiText>
<EuiText>
[{/* shard id */ shard.id[0]}][{/* shard number */ shard.id[2]}]
</EuiText>
<EuiText>{shardName}</EuiText>
</EuiFlyoutHeader>
<EuiFlyoutBody>
<EuiText>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const HighlightDetailsTable = ({ breakdown }: Props) => {
{
name: 'Percentage',
render: (item: BreakdownItem) => (
<PercentageBadge timePercentage={item.relative as number} label={item.relative + '%'} />
<PercentageBadge timePercentage={String(item.relative)} label={item.relative + '%'} />
),
},
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { EuiBadge } from '@elastic/eui';
import classNames from 'classnames';

interface Props {
timePercentage: number;
timePercentage: string;
label: string;
valueType?: 'percent' | 'time';
}
Expand Down
Loading

0 comments on commit 753eb53

Please sign in to comment.