Skip to content

[Investigations][Timeline] - Run Object.keys less frequently#219629

Merged
michaelolo24 merged 2 commits intoelastic:mainfrom
michaelolo24:small-timeline-perf-improvement
Apr 30, 2025
Merged

[Investigations][Timeline] - Run Object.keys less frequently#219629
michaelolo24 merged 2 commits intoelastic:mainfrom
michaelolo24:small-timeline-perf-improvement

Conversation

@michaelolo24
Copy link
Contributor

@michaelolo24 michaelolo24 commented Apr 29, 2025

Summary

This PR makes a minor performance improvement by pulling out the Object.keys call on hit.fields out of any unnecessary loops.

@michaelolo24 michaelolo24 added release_note:skip Skip the PR/issue when compiling release notes backport:version Backport to applied version labels v9.1.0 v8.19.0 v9.0.1 v8.18.2 labels Apr 29, 2025
@michaelolo24 michaelolo24 requested a review from a team as a code owner April 29, 2025 20:03
fields &&
Object.keys(fields).find((field) => field !== fieldPath && fieldPath.startsWith(`${field}.`));
fields: string[],
): string | undefined => fields.find((field) => field !== fieldPath && fieldPath.startsWith(`${field}.`));
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 is the primary change. getNestedParentPath is called in a few looping constructs, and hitting Object.keys() on each iteration wasn't performant

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

@michaelolo24 michaelolo24 added the Team:Threat Hunting:Investigations Security Solution Threat Hunting Investigations Team label Apr 30, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-threat-hunting-investigations (Team:Threat Hunting:Investigations)

Copy link
Contributor

@janmonschke janmonschke left a comment

Choose a reason for hiding this comment

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

Nice catch! Given hit.fields can potentially be huge, this could have quite some impact :)

@michaelolo24 michaelolo24 merged commit fd4ff0a into elastic:main Apr 30, 2025
11 checks passed
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.18, 8.19, 9.0

https://github.com/elastic/kibana/actions/runs/14757531244

kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Apr 30, 2025
…#219629)

## Summary

This PR makes a minor performance improvement by pulling out the
`Object.keys` call on `hit.fields` out of any unnecessary loops.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit fd4ff0a)
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Apr 30, 2025
…#219629)

## Summary

This PR makes a minor performance improvement by pulling out the
`Object.keys` call on `hit.fields` out of any unnecessary loops.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit fd4ff0a)
kibanamachine added a commit to kibanamachine/kibana that referenced this pull request Apr 30, 2025
…#219629)

## Summary

This PR makes a minor performance improvement by pulling out the
`Object.keys` call on `hit.fields` out of any unnecessary loops.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
(cherry picked from commit fd4ff0a)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.18
8.19
9.0

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Apr 30, 2025
…219629) (#219750)

# Backport

This will backport the following commits from `main` to `9.0`:
- [[Investigations][Timeline] - Run Object.keys less frequently
(#219629)](#219629)

<!--- Backport version: 9.6.6 -->

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

<!--BACKPORT [{"author":{"name":"Michael
Olorunnisola","email":"michael.olorunnisola@elastic.co"},"sourceCommit":{"committedDate":"2025-04-30T14:50:46Z","message":"[Investigations][Timeline]
- Run Object.keys less frequently (#219629)\n\n## Summary\n\nThis PR
makes a minor performance improvement by pulling out the\n`Object.keys`
call on `hit.fields` out of any unnecessary
loops.\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"fd4ff0a2e872d7ba778c3de138e5919a29d61220","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Threat
Hunting:Investigations","backport:version","v9.1.0","v8.19.0","v9.0.1","v8.18.2"],"title":"[Investigations][Timeline]
- Run Object.keys less
frequently","number":219629,"url":"https://github.com/elastic/kibana/pull/219629","mergeCommit":{"message":"[Investigations][Timeline]
- Run Object.keys less frequently (#219629)\n\n## Summary\n\nThis PR
makes a minor performance improvement by pulling out the\n`Object.keys`
call on `hit.fields` out of any unnecessary
loops.\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"fd4ff0a2e872d7ba778c3de138e5919a29d61220"}},"sourceBranch":"main","suggestedTargetBranches":["8.19","9.0","8.18"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/219629","number":219629,"mergeCommit":{"message":"[Investigations][Timeline]
- Run Object.keys less frequently (#219629)\n\n## Summary\n\nThis PR
makes a minor performance improvement by pulling out the\n`Object.keys`
call on `hit.fields` out of any unnecessary
loops.\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"fd4ff0a2e872d7ba778c3de138e5919a29d61220"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.0","label":"v9.0.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.2","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Michael Olorunnisola <michael.olorunnisola@elastic.co>
pborgonovi pushed a commit that referenced this pull request Apr 30, 2025
## Summary

This PR makes a minor performance improvement by pulling out the
`Object.keys` call on `hit.fields` out of any unnecessary loops.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label May 2, 2025
@kibanamachine
Copy link
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.
cc: @michaelolo24

1 similar comment
@kibanamachine
Copy link
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.
cc: @michaelolo24

@mistic mistic removed the v9.0.1 label May 6, 2025
@mistic mistic added the v9.0.2 label May 6, 2025
@mistic
Copy link
Contributor

mistic commented May 6, 2025

This PR didn't make it into the latest 9.0.1 BC. Updating the labels.

@kibanamachine
Copy link
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.
cc: @michaelolo24

kibanamachine added a commit that referenced this pull request May 7, 2025
…219629) (#219749)

# Backport

This will backport the following commits from `main` to `8.19`:
- [[Investigations][Timeline] - Run Object.keys less frequently
(#219629)](#219629)

<!--- Backport version: 9.6.6 -->

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

<!--BACKPORT [{"author":{"name":"Michael
Olorunnisola","email":"michael.olorunnisola@elastic.co"},"sourceCommit":{"committedDate":"2025-04-30T14:50:46Z","message":"[Investigations][Timeline]
- Run Object.keys less frequently (#219629)\n\n## Summary\n\nThis PR
makes a minor performance improvement by pulling out the\n`Object.keys`
call on `hit.fields` out of any unnecessary
loops.\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"fd4ff0a2e872d7ba778c3de138e5919a29d61220","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Threat
Hunting:Investigations","backport:version","v9.1.0","v8.19.0","v9.0.1","v8.18.2"],"title":"[Investigations][Timeline]
- Run Object.keys less
frequently","number":219629,"url":"https://github.com/elastic/kibana/pull/219629","mergeCommit":{"message":"[Investigations][Timeline]
- Run Object.keys less frequently (#219629)\n\n## Summary\n\nThis PR
makes a minor performance improvement by pulling out the\n`Object.keys`
call on `hit.fields` out of any unnecessary
loops.\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"fd4ff0a2e872d7ba778c3de138e5919a29d61220"}},"sourceBranch":"main","suggestedTargetBranches":["8.19","9.0","8.18"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/219629","number":219629,"mergeCommit":{"message":"[Investigations][Timeline]
- Run Object.keys less frequently (#219629)\n\n## Summary\n\nThis PR
makes a minor performance improvement by pulling out the\n`Object.keys`
call on `hit.fields` out of any unnecessary
loops.\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"fd4ff0a2e872d7ba778c3de138e5919a29d61220"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.0","label":"v9.0.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.2","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Michael Olorunnisola <michael.olorunnisola@elastic.co>
kibanamachine added a commit that referenced this pull request May 7, 2025
…219629) (#219748)

# Backport

This will backport the following commits from `main` to `8.18`:
- [[Investigations][Timeline] - Run Object.keys less frequently
(#219629)](#219629)

<!--- Backport version: 9.6.6 -->

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

<!--BACKPORT [{"author":{"name":"Michael
Olorunnisola","email":"michael.olorunnisola@elastic.co"},"sourceCommit":{"committedDate":"2025-04-30T14:50:46Z","message":"[Investigations][Timeline]
- Run Object.keys less frequently (#219629)\n\n## Summary\n\nThis PR
makes a minor performance improvement by pulling out the\n`Object.keys`
call on `hit.fields` out of any unnecessary
loops.\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"fd4ff0a2e872d7ba778c3de138e5919a29d61220","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Threat
Hunting:Investigations","backport:version","v9.1.0","v8.19.0","v9.0.1","v8.18.2"],"title":"[Investigations][Timeline]
- Run Object.keys less
frequently","number":219629,"url":"https://github.com/elastic/kibana/pull/219629","mergeCommit":{"message":"[Investigations][Timeline]
- Run Object.keys less frequently (#219629)\n\n## Summary\n\nThis PR
makes a minor performance improvement by pulling out the\n`Object.keys`
call on `hit.fields` out of any unnecessary
loops.\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"fd4ff0a2e872d7ba778c3de138e5919a29d61220"}},"sourceBranch":"main","suggestedTargetBranches":["8.19","9.0","8.18"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/219629","number":219629,"mergeCommit":{"message":"[Investigations][Timeline]
- Run Object.keys less frequently (#219629)\n\n## Summary\n\nThis PR
makes a minor performance improvement by pulling out the\n`Object.keys`
call on `hit.fields` out of any unnecessary
loops.\n\n---------\n\nCo-authored-by: kibanamachine
<42973632+kibanamachine@users.noreply.github.com>","sha":"fd4ff0a2e872d7ba778c3de138e5919a29d61220"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"9.0","label":"v9.0.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.2","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Michael Olorunnisola <michael.olorunnisola@elastic.co>
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label May 7, 2025
akowalska622 pushed a commit to akowalska622/kibana that referenced this pull request May 29, 2025
…#219629)

## Summary

This PR makes a minor performance improvement by pulling out the
`Object.keys` call on `hit.fields` out of any unnecessary loops.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels release_note:skip Skip the PR/issue when compiling release notes Team:Threat Hunting:Investigations Security Solution Threat Hunting Investigations Team v8.18.2 v8.19.0 v9.0.2 v9.1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants