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

perf(table): optimize tableForSelection calls #3486

Merged
merged 3 commits into from
Apr 16, 2024

Conversation

marcelgerber
Copy link
Member

@marcelgerber marcelgerber commented Apr 12, 2024

I noticed some performance problems with the tableForSelection call, and specifically the transformTableForSelection method in chart instances, while reviewing #3447.

So, I got at it and could quite improve these 🚀


What I did to check that this is correct:
I just loaded up 10-or-so different charts with missingDataStrategy = 'hide', ran grapher.tableForSelection.dump(), and compared stats like numRows, numValidCells, and numErrorValues across live and localhost.
They are all the same everywhere.

Comment on lines -106 to -114
const groupedByEntity = table
.groupBy(table.entityNameColumn.slug)
.map((t: OwidTable) =>
t.dropRowsWithErrorValuesForAnyColumn(this.yColumnSlugs)
)

if (groupedByEntity.length === 0) return BlankOwidTable()

table = groupedByEntity[0].concat(groupedByEntity.slice(1))
Copy link
Member Author

Choose a reason for hiding this comment

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

Turns out, this here never needed the groupBy call at all: dropRowsWithErrorValuesForAnyColumn is entirely row-based, and decides on a row-by-row basis.

Copy link
Member

@sophiamersmann sophiamersmann left a comment

Choose a reason for hiding this comment

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

Sweet!

@marcelgerber marcelgerber merged commit c7e732b into master Apr 16, 2024
22 checks passed
@marcelgerber marcelgerber deleted the perf-table-for-selection branch April 16, 2024 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants