Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Field: Fix perf regression in getUniqueFieldName() #81323

Merged
merged 8 commits into from
Jan 26, 2024

Conversation

leeoniya
Copy link
Contributor

@leeoniya leeoniya commented Jan 26, 2024

Addresses https://github.com/grafana/support-escalations/issues/9134

this fixes a large perf regression in getFieldDisplayName() introduced in #75511

@ryantxu should we backport this?

NOTE: easiest to review each commit separately. the first one is the fix, the second one is an additional optimization for huge-field-count frames.

@leeoniya leeoniya added type/bug type/performance no-backport Skip backport of PR no-changelog Skip including change in changelog/release notes labels Jan 26, 2024
@leeoniya leeoniya self-assigned this Jan 26, 2024
@leeoniya leeoniya requested review from a team as code owners January 26, 2024 04:35
@leeoniya leeoniya requested review from joshhunt, L-M-K-B and academo and removed request for a team January 26, 2024 04:35
@grafana-delivery-bot grafana-delivery-bot bot added this to the 10.4.x milestone Jan 26, 2024
@@ -167,7 +165,7 @@ export function getUniqueFieldName(field: Field, frame?: DataFrame) {
for (let i = 0; i < frame.fields.length; i++) {
const otherField = frame.fields[i];

if (isEqual(field, otherField)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

root cause of slowdown

Comment on lines -44 to -46
const fields = data.fields.map((f, idx) => {
return { ...f, hovered: idx === columnIndex };
});
Copy link
Contributor Author

@leeoniya leeoniya Jan 26, 2024

Choose a reason for hiding this comment

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

this field copy is why === was failing inside getUniqueFieldName(), and resulting in the 1 suffix, which is the original issue #75511 was attempting to fix.

@grafana-pr-automation grafana-pr-automation bot requested review from a team and removed request for a team January 26, 2024 04:39
@grafana-pr-automation grafana-pr-automation bot requested review from a team and removed request for a team January 26, 2024 05:03
@joshhunt
Copy link
Contributor

this should fix #80039 also?

@ryantxu
Copy link
Member

ryantxu commented Jan 26, 2024

If the isEqual approach is in 10.3, then yes, this should be backported

@grafana-pr-automation grafana-pr-automation bot removed the request for review from a team January 26, 2024 16:52
Copy link
Contributor

@nmarrs nmarrs left a comment

Choose a reason for hiding this comment

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

I think with a bit of clean up this is G2G 💨

packages/grafana-data/src/field/fieldState.ts Outdated Show resolved Hide resolved
@grafana-pr-automation grafana-pr-automation bot requested review from a team and removed request for a team January 26, 2024 17:02
@grafana-pr-automation grafana-pr-automation bot requested review from a team and removed request for a team January 26, 2024 22:11
@grafana-pr-automation grafana-pr-automation bot requested review from a team and removed request for a team January 26, 2024 22:17
@grafana-pr-automation grafana-pr-automation bot requested review from a team and removed request for a team January 26, 2024 22:21
@leeoniya leeoniya enabled auto-merge (squash) January 26, 2024 22:21
@leeoniya leeoniya merged commit 0530021 into main Jan 26, 2024
19 checks passed
@leeoniya leeoniya deleted the leeoniya/fieldState-perf-fix branch January 26, 2024 22:32
grafana-delivery-bot bot pushed a commit that referenced this pull request Jan 26, 2024
Co-authored-by: nmarrs <nathanielmarrs@gmail.com>
(cherry picked from commit 0530021)
grafana-delivery-bot bot pushed a commit that referenced this pull request Jan 26, 2024
Co-authored-by: nmarrs <nathanielmarrs@gmail.com>
(cherry picked from commit 0530021)
leeoniya added a commit that referenced this pull request Jan 26, 2024
Field: Fix perf regression in getUniqueFieldName() (#81323)

Co-authored-by: nmarrs <nathanielmarrs@gmail.com>
(cherry picked from commit 0530021)

Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
leeoniya added a commit that referenced this pull request Jan 26, 2024
* Field: Fix perf regression in getUniqueFieldName() (#81323)

Co-authored-by: nmarrs <nathanielmarrs@gmail.com>
(cherry picked from commit 0530021)

* Chore: Fix some Explore deprecations (#80076)

* lint

---------

Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
Co-authored-by: Giordano Ricci <me@giordanoricci.com>
Ukochka pushed a commit that referenced this pull request Feb 14, 2024
Co-authored-by: nmarrs <nathanielmarrs@gmail.com>
@aangelisc aangelisc modified the milestones: 10.4.x, 10.4.0 Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants