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

feat(track): performance improvements #988

Merged
merged 40 commits into from
Dec 4, 2023

Conversation

etowahadams
Copy link
Contributor

@etowahadams etowahadams commented Nov 2, 2023

Fix #
Toward #

Change List

Checklist

  • Ensure the PR works with all demos on the online editor
  • Unit tests added or updated
  • Examples added or updated
  • Documentation updated (e.g., added API functions)
  • Screenshots for visual changes (e.g., new encoding support or UI change on Editor)

@etowahadams etowahadams changed the title Etowahadams/playwright perf Playwright performance testing Nov 2, 2023
@etowahadams etowahadams changed the title Playwright performance testing feat: playwright performance testing Nov 3, 2023
@etowahadams
Copy link
Contributor Author

Zooming works (after much trial and error). However it is still more choppy than I would like. Not sure that there's an obvious solution.

@etowahadams etowahadams changed the title feat: playwright performance testing feat(track): performance improvements Nov 7, 2023
@etowahadams
Copy link
Contributor Author

For reasons still unclear to me, it seems that occasionally the first zoom/pan event has a lower frame rate compared to subsequent interactions.

@etowahadams etowahadams marked this pull request as ready for review November 16, 2023 21:34
@etowahadams
Copy link
Contributor Author

Last thing to do here is just to add the same visual regression testing from #962

@etowahadams
Copy link
Contributor Author

/update-snapshots

1 similar comment
@etowahadams
Copy link
Contributor Author

/update-snapshots

@etowahadams
Copy link
Contributor Author

test

@etowahadams
Copy link
Contributor Author

/update-snapshots

@etowahadams
Copy link
Contributor Author

I spent quite a bit of time getting automatic snapshot testing working in CI, but without luck. Maybe it needs to be merged before it can be triggered from a comment? Will have to do additional testing. Going to reduce the scope of this to just adding the performance test and the performance related changes.


this.specOriginal = JSON.parse(JSON.stringify(spec));
this.specComplete = JSON.parse(JSON.stringify(spec));
this.specOriginal = spec;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

specOrigional never gets modified so we don't need to make a clone of it

Copy link
Member

Choose a reason for hiding this comment

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

Nice catch!

Comment on lines 808 to 819
getResolvedTracks() {
if (!this.resolvedTracks) {
const copy = structuredClone(this.options.spec);
const tracks = resolveSuperposedTracks(copy).filter(t => t.mark !== 'brush');
// We will never need to access the values field in the data spec. It can be quite large which can degrade performance so we remove it.
tracks.forEach(track => {
if ('values' in track.data) {
track.data.values = [];
}
});
this.resolvedTracks = tracks;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rather than creating a resolved spec every time, we make it once and reuse it.

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 tried to come up with ways in creating a new resolved spec at every render is needed but couldn't think of one. Sehi do you know if there are any?

Copy link
Member

@sehilyi sehilyi Nov 29, 2023

Choose a reason for hiding this comment

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

It is possible that the track spec can be edited by users even after the track has been rendered, so we would need to force updating resolvedTracks when this happens. override rerender(newOptions: GoslingTrackOptions) is the function that is called when a user edits a track spec, so we can update resolvedTracks inside the function.

I don't think this will decrease the performance though since this function is called only when the user manually edits the spec.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's exactly what I was looking for, thank you! Just changed.

@etowahadams etowahadams requested a review from sehilyi November 22, 2023 00:19
Comment on lines +812 to +817
// We will never need to access the values field in the data spec. It can be quite large which can degrade performance so we remove it.
tracks.forEach(track => {
if ('values' in track.data) {
track.data.values = [];
}
});
Copy link
Member

Choose a reason for hiding this comment

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

❤️

Copy link
Member

@sehilyi sehilyi left a comment

Choose a reason for hiding this comment

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

I reviewed the code changes mainly related to the renderer, i.e., changes in gosling-track.ts and gosling-track-model.ts, and left one comment to force updating resolvedTracks when a user manually edits the spec. I will need to find more time to look at other updates (playwright), but please feel free to merge this after addressing the comment.

@etowahadams etowahadams merged commit edd24de into master Dec 4, 2023
5 checks passed
@etowahadams etowahadams deleted the etowahadams/playwright-perf branch December 4, 2023 15: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