Skip to content

Commit

Permalink
Add totalMemory in config for trace graph (jaegertracing#1262)
Browse files Browse the repository at this point in the history
Trace graph has a problem to renders large traces (with ~15K+ spans),
and gives the error "Cannot enlarge memory arrays". Need to give users
flexibility to control the totalMemory of LayoutManager used for
TraceGraph.

<!--
Please delete this comment before posting.

We appreciate your contribution to the Jaeger project! 👋🎉

Before creating a pull request, please make sure:
- Your PR is solving one problem
- You have read the guide for contributing
- See
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING.md
- You signed all your commits (otherwise we won't be able to merge the
PR)
- See
https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md#certificate-of-origin---sign-your-work
- You added unit tests for the new functionality
- You mention in the PR description which issue it is addressing, e.g.
"Resolves jaegertracing#123"
-->

- Resolves jaegertracing#1249

Trace graph has a problem to renders large traces (with ~15K+ spans),
and gives the error "Cannot enlarge memory arrays". This can be fixed by
providing a larger number of memory when initializing the
`LayoutManager` in trace graph, like below:
```
// default 16MB
this.layoutManager = new LayoutManager({ totalMemory: 33554432, useDotEdges: true, splines: 'polyline' });
```
But instead of hardcoding the memory value in code, we want to give
users the flexibility to control the totalMemory of LayoutManager for
TraceGraph.

Signed-off-by: Chen Xu <[email protected]>
  • Loading branch information
ChenX1993 authored and Benjamin Klein committed Apr 18, 2023
1 parent c4a9542 commit 3d1a275
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { TEv, TSumSpan } from './types';
import { TDenseSpanMembers } from '../../../model/trace-dag/types';
import TDagPlexusVertex from '../../../model/trace-dag/types/TDagPlexusVertex';
import { TNil } from '../../../types';
import { TraceGraphConfig } from '../../../types/config';

import './TraceGraph.css';

Expand All @@ -39,6 +40,7 @@ type Props = {
ev?: TEv | TNil;
uiFind: string | TNil;
uiFindVertexKeys: Set<string> | TNil;
traceGraphConfig?: TraceGraphConfig;
};
type State = {
showHelp: boolean;
Expand Down Expand Up @@ -129,7 +131,11 @@ export default class TraceGraph extends React.PureComponent<Props, State> {
showHelp: false,
mode: MODE_SERVICE,
};
this.layoutManager = new LayoutManager({ useDotEdges: true, splines: 'polyline' });
this.layoutManager = new LayoutManager({
totalMemory: props.traceGraphConfig?.layoutManagerMemory,
useDotEdges: true,
splines: 'polyline',
});
}

componentWillUnmount() {
Expand Down
16 changes: 16 additions & 0 deletions packages/jaeger-ui/src/components/TracePage/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -793,4 +793,20 @@ describe('mapStateToProps()', () => {
trace: { data: {}, state: fetchedState.DONE },
});
});

it('propagates layoutManagerMemory correctly', () => {
const fakeMemory = 123;
state.config.traceGraph = { layoutManagerMemory: fakeMemory };
const props = mapStateToProps(state, ownProps);
expect(props).toEqual({
id: traceID,
embedded,
archiveEnabled: false,
archiveTraceState: undefined,
searchUrl: null,
uiFind: undefined,
trace: { data: {}, state: fetchedState.DONE },
traceGraphConfig: { layoutManagerMemory: fakeMemory },
});
});
});
6 changes: 6 additions & 0 deletions packages/jaeger-ui/src/components/TracePage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import updateUiFind from '../../utils/update-ui-find';
import TraceStatistics from './TraceStatistics/index';
import TraceSpanView from './TraceSpanView/index';
import TraceFlamegraph from './TraceFlamegraph/index';
import { TraceGraphConfig } from '../../types/config';

import './index.css';

Expand All @@ -83,6 +84,7 @@ type TReduxProps = {
searchUrl: null | string;
trace: FetchedTrace | TNil;
uiFind: string | TNil;
traceGraphConfig?: TraceGraphConfig;
};

type TProps = TDispatchProps & TOwnProps & TReduxProps;
Expand Down Expand Up @@ -329,6 +331,7 @@ export class TracePageImpl extends React.PureComponent<TProps, TState> {
id,
uiFind,
trace,
traceGraphConfig,
location: { state: locationState },
} = this.props;
const { slimView, viewType, headerHeight, viewRange } = this.state;
Expand Down Expand Up @@ -406,6 +409,7 @@ export class TracePageImpl extends React.PureComponent<TProps, TState> {
ev={this.traceDagEV}
uiFind={uiFind}
uiFindVertexKeys={graphFindMatches}
traceGraphConfig={traceGraphConfig}
/>
);
} else if (ETraceViewType.TraceStatistics === viewType && headerHeight) {
Expand Down Expand Up @@ -441,6 +445,7 @@ export function mapStateToProps(state: ReduxState, ownProps: TOwnProps): TReduxP
const archiveEnabled = Boolean(config.archiveEnabled);
const { state: locationState } = router.location;
const searchUrl = (locationState && locationState.fromSearch) || null;
const { traceGraph: traceGraphConfig } = config;

return {
...extractUiFindFromState(state),
Expand All @@ -451,6 +456,7 @@ export function mapStateToProps(state: ReduxState, ownProps: TOwnProps): TReduxP
id,
searchUrl,
trace,
traceGraphConfig,
};
}

Expand Down
5 changes: 5 additions & 0 deletions packages/jaeger-ui/src/constants/default-config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ const defaultConfig: Config = {
},
forbidNewPage: false,
disableFileUploadControl: false,

traceGraph: {
layoutManagerMemory: undefined,
},

deepDependencies: {
menuEnabled: false,
},
Expand Down
11 changes: 11 additions & 0 deletions packages/jaeger-ui/src/types/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ export type MonitorConfig = {
docsLink?: string;
};

export type TraceGraphConfig = {
// layoutManagerMemory controls the total memeory available for the GraphViz
// Emscripten module instance. The value should be a power of two.
// The default of 16MB should be sufficient for most cases — only consider
// using a larger number if you run into the error "Cannot enlarge memory arrays".
// See https://github.com/jaegertracing/jaeger-ui/issues/1249 for background
layoutManagerMemory?: number;
};

// Default values are provided in packages/jaeger-ui/src/constants/default-config.tsx
export type Config = {
// archiveEnabled enables the Archive Trace button in the trace view.
Expand Down Expand Up @@ -160,6 +169,8 @@ export type Config = {

// Disables the file upload control.
disableFileUploadControl: boolean;
// traceGraph controls the trace graph under trace page
traceGraph?: TraceGraphConfig;

// The following features are experimental / undocumented.

Expand Down

0 comments on commit 3d1a275

Please sign in to comment.