Skip to content

Conversation

@oatkiller
Copy link
Contributor

@oatkiller oatkiller commented Jul 18, 2020

Summary

  • Memoize various selectors
  • Improve performance of the selectors that calculate the aria-flowto attribute.
  • more tests.

No behaviour changes intended.

screenshot at 546079d

image

Checklist

For maintainers

@oatkiller oatkiller requested review from a team as code owners July 18, 2020 20:22
@oatkiller oatkiller added release_note:skip Skip the PR/issue when compiling release notes v7.9.0 labels Jul 18, 2020
export function children(tree: IndexedProcessTree, process: ResolverEvent): ResolverEvent[] {
const id = uniquePidForProcess(process);
const currentProcessSiblings = tree.idToChildren.get(id);
export function children(tree: IndexedProcessTree, parentID: string | undefined): ResolverEvent[] {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can return children for a node that isn't in the tree itself. For example, the root node of the tree may have a parent that isn't in the tree. Also, the root node may have no parent (undefined.)

if (rootNode !== null) {
yield* baseLevelOrder(rootNode, children.bind(null, tree));
yield* baseLevelOrder(rootNode, (parentNode: ResolverEvent): ResolverEvent[] =>
children(tree, uniquePidForProcess(parentNode))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

children now takes an id, since the parent may not be in-memory.


for (const process of processesInReverseLevelOrder) {
const children = model.children(indexedProcessTree, process);
const children = model.children(indexedProcessTree, uniquePidForProcess(process));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

children now takes an id, since the parent may not be in-memory.

};

const siblings = model.children(indexedProcessTree, parent);
const siblings = model.children(indexedProcessTree, uniquePidForProcess(parent));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

children now takes an id, since the parent may not be in-memory.

};

const siblings = model.children(tree, parent);
const siblings = model.children(tree, uniquePidForProcess(parent));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

children now takes an id, since the parent may not be in-memory.

* Process events that will be graphed.
*/
export const graphableProcesses = createSelector(resolverTree, function (tree?) {
export const graphableProcesses = createSelector(resolverTreeResponse, function (tree?) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renaming stuff

* we're currently interested in.
*/
const resolverTree = (state: DataState): ResolverTree | undefined => {
const resolverTreeResponse = (state: DataState): ResolverTree | undefined => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renaming stuff

export function hasMoreChildren(state: DataState): boolean {
const tree = resolverTree(state);
return tree ? resolverTreeModel.hasMoreChildren(tree) : false;
const resolverTree = resolverTreeResponse(state);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renaming stuff

export function hasMoreAncestors(state: DataState): boolean {
const tree = resolverTree(state);
return tree ? resolverTreeModel.hasMoreAncestors(tree) : false;
const resolverTree = resolverTreeResponse(state);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renaming stuff

});
};

const matchingEventsForCategory = defaultMemoize(unmemoizedMatchingEventsForCategory);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be garbage collected as there is no dominator

* Calls the `secondSelector` with the result of the `selector`. Use this when re-exporting a
* concern-specific selector. `selector` should return the concern-specific state.
*/
function composeSelectors<OuterState, InnerState, ReturnValue>(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to bottom of file

@oatkiller oatkiller mentioned this pull request Jul 19, 2020
11 tasks
@oatkiller oatkiller force-pushed the selector-performance branch from bbce3b1 to 546079d Compare July 19, 2020 06:08
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

async chunks size

id value diff baseline
securitySolution 7.3MB +496.0B 7.3MB

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream


return (time) => {
// memoizing this so the vector returned will be the same object reference if called with the same `time`.
return defaultMemoize((time) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason to not do this for all of the time based selectors?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't do it for isAnimating because it returns a primitive and is trivial enough that there should be no perf gain to memoizing.
I didn't do it for visibleNodesAndEdgeLines because it just calls two functions which are each already memoized.
I think I did it everywhere else.

@oatkiller oatkiller merged commit 6cf796a into elastic:master Jul 20, 2020
@oatkiller oatkiller deleted the selector-performance branch July 20, 2020 13:38
oatkiller pushed a commit to oatkiller/kibana that referenced this pull request Jul 20, 2020
* Memoize various selectors
* Improve performance of the selectors that calculate the `aria-flowto` attribute.
* more tests.
oatkiller pushed a commit to oatkiller/kibana that referenced this pull request Jul 20, 2020
* Memoize various selectors
* Improve performance of the selectors that calculate the `aria-flowto` attribute.
* more tests.
oatkiller pushed a commit that referenced this pull request Jul 20, 2020
* Memoize various selectors
* Improve performance of the selectors that calculate the `aria-flowto` attribute.
* more tests.
oatkiller pushed a commit that referenced this pull request Jul 20, 2020
* Memoize various selectors
* Improve performance of the selectors that calculate the `aria-flowto` attribute.
* more tests.
gmmorris added a commit to gmmorris/kibana that referenced this pull request Jul 20, 2020
* master: (60 commits)
  [SIEM][Detection Engine][Lists] Adds list permissions (elastic#72335)
  [SIEM][Detection Engine][Lists] Adds conflict versioning and io-ts improvements to lists (elastic#72337)
  [Resolver] no longer pass related event stats to process node component (elastic#72435)
  Revert "skip flaky suite (elastic#72146)"
  [Security Solution] Cleanup endpoint telemetry (elastic#71950)
  Unskip dashboard embeddable rendering tests (elastic#71824)
  [ENDPOINT] Added unerolling status for host. (elastic#72303)
  [Alerting][Connectors] Increase the size of the logos (elastic#72419)
  [SECURITY] [Timeline] Raw events not displayed (elastic#72387)
  [ML] Fixes display of regression stop stats if one is NaN (elastic#72412)
  [Ingest Pipelines] Processor Editor Move Tooltip (elastic#72239)
  Fix match phrase and not match phrase comparators (elastic#71850)
  [Plugin Generator] Generate tsconfig and useDefaultBehaviors (elastic#72040)
  [Security Solution][Timeline] Fix timeline styling and createFrom beh… (elastic#72152)
  [Resolver] Selector performance (elastic#72380)
  [Ingest Manager] Set `_meta` in the index.mappings (elastic#72026)
  [Ingest Manager] Do not bumb config revision during config creation (elastic#72270)
  [ML] Adding missing index pattern name to new job wizards (elastic#72400)
  [ML] improve annotation flyout performance (elastic#72299)
  [APM] Testing error rate API and restructuring folders (elastic#72257)
  ...
gmmorris added a commit to gmmorris/kibana that referenced this pull request Jul 20, 2020
* master: (26 commits)
  [SIEM][Detection Engine][Lists] Adds list permissions (elastic#72335)
  [SIEM][Detection Engine][Lists] Adds conflict versioning and io-ts improvements to lists (elastic#72337)
  [Resolver] no longer pass related event stats to process node component (elastic#72435)
  Revert "skip flaky suite (elastic#72146)"
  [Security Solution] Cleanup endpoint telemetry (elastic#71950)
  Unskip dashboard embeddable rendering tests (elastic#71824)
  [ENDPOINT] Added unerolling status for host. (elastic#72303)
  [Alerting][Connectors] Increase the size of the logos (elastic#72419)
  [SECURITY] [Timeline] Raw events not displayed (elastic#72387)
  [ML] Fixes display of regression stop stats if one is NaN (elastic#72412)
  [Ingest Pipelines] Processor Editor Move Tooltip (elastic#72239)
  Fix match phrase and not match phrase comparators (elastic#71850)
  [Plugin Generator] Generate tsconfig and useDefaultBehaviors (elastic#72040)
  [Security Solution][Timeline] Fix timeline styling and createFrom beh… (elastic#72152)
  [Resolver] Selector performance (elastic#72380)
  [Ingest Manager] Set `_meta` in the index.mappings (elastic#72026)
  [Ingest Manager] Do not bumb config revision during config creation (elastic#72270)
  [ML] Adding missing index pattern name to new job wizards (elastic#72400)
  [ML] improve annotation flyout performance (elastic#72299)
  [APM] Testing error rate API and restructuring folders (elastic#72257)
  ...
gmmorris added a commit to gmmorris/kibana that referenced this pull request Jul 21, 2020
…feature-privileges

* alerting/consumer-based-rbac: (45 commits)
  fixed alerts test
  [SIEM][Detection Engine][Lists] Adds list permissions (elastic#72335)
  [SIEM][Detection Engine][Lists] Adds conflict versioning and io-ts improvements to lists (elastic#72337)
  [Resolver] no longer pass related event stats to process node component (elastic#72435)
  Revert "skip flaky suite (elastic#72146)"
  [Security Solution] Cleanup endpoint telemetry (elastic#71950)
  Unskip dashboard embeddable rendering tests (elastic#71824)
  [ENDPOINT] Added unerolling status for host. (elastic#72303)
  [Alerting][Connectors] Increase the size of the logos (elastic#72419)
  [SECURITY] [Timeline] Raw events not displayed (elastic#72387)
  [ML] Fixes display of regression stop stats if one is NaN (elastic#72412)
  [Ingest Pipelines] Processor Editor Move Tooltip (elastic#72239)
  Fix match phrase and not match phrase comparators (elastic#71850)
  [Plugin Generator] Generate tsconfig and useDefaultBehaviors (elastic#72040)
  [Security Solution][Timeline] Fix timeline styling and createFrom beh… (elastic#72152)
  allow user to disable alert even if they dont have privileges to the underlying action
  [Resolver] Selector performance (elastic#72380)
  [Ingest Manager] Set `_meta` in the index.mappings (elastic#72026)
  [Ingest Manager] Do not bumb config revision during config creation (elastic#72270)
  [ML] Adding missing index pattern name to new job wizards (elastic#72400)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release_note:skip Skip the PR/issue when compiling release notes v7.9.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants