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

⚡ Don't re-render the plugin repository if notmodified #4132

Merged
merged 1 commit into from
May 11, 2021

Conversation

cp2004
Copy link
Member

@cp2004 cp2004 commented May 9, 2021

What does this PR do and why is it necessary?

Don't re-render the plugin repository if the server responds with notmodified. This shaves ~500ms off the total processing time, making opening the settings dialog lightning fast ⚡.

How was it tested? How can it be tested by the reviewer?

Using the performance profiler, first I identified the issue, then opened and closes the settings dialogs several times, to make sure this change was effective.

Any background context you want to provide?

General push to improve UI performance, started with the animations, onto the data processing...

What are the relevant tickets if any?

Closes #4131

Screenshots (if appropriate)

image
Look, barely a dropped frame...

Comparison to before this change:
117578894-824e4180-b0e8-11eb-81c0-5380ecaad93a

Further notes

Ok, now another question. I noticed some of the other endpoints that are processed repeatedly like this, and wondered if it would make sense to implement the same thing?

It has to be on a per-request basis, since adding ifModified: true to all request options breaks handlers that are not expecting an empty response.

@github-actions github-actions bot added the approved Issue has been approved by the bot or manually for further processing label May 9, 2021
@cp2004
Copy link
Member Author

cp2004 commented May 9, 2021

Further notes
Ok, now another question. I noticed some of the other endpoints that are processed repeatedly like this, and wondered if it would make sense to implement the same thing?

It has to be on a per-request basis, since adding ifModified: true to all request options breaks handlers that are not expecting an empty response.

For reference, the additional processing done here adds up to less than 100ms for me.

.done(function (data, status, xhr) {
// Don't update if cached - requires ifModified: true to pass through
// the 304 status, otherwise it fakes it and produces 200 all the time.
if (xhr.status === 304) return;
Copy link
Member Author

Choose a reason for hiding this comment

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

Thought of the day - if this case is hit, does the promise ever get resolved/rejected? Might need to look at that. Just a thought that crossed my head...

Copy link
Member

Choose a reason for hiding this comment

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

From my understanding it should not interfere. The done callback has no way to interfere with the promise processing, it's just a callback and returning from it won't affect any other callbacks.

@foosel foosel merged commit 0ad9690 into OctoPrint:maintenance May 11, 2021
@foosel
Copy link
Member

foosel commented May 11, 2021

Ok, now another question. I noticed some of the other endpoints that are processed repeatedly like this, and wondered if it would make sense to implement the same thing?

It has to be on a per-request basis, since adding ifModified: true to all request options breaks handlers that are not expecting an empty response.

First of all, definitely makes sense. Would it be a good idea to do that on the client lib layer instead of in the viewmodels?

@foosel foosel added this to the 1.7.0 milestone May 11, 2021
@cp2004
Copy link
Member Author

cp2004 commented May 11, 2021

First of all, definitely makes sense. Would it be a good idea to do that on the client lib layer instead of in the viewmodels?

The only thing about that is that it would technically be a breaking change - since data is undefined - a 304 has no content, by it's nature. If you are expecting some data, you now don't get it. Since the change is not network/request related, but actually viewmodel rendering it made sense to me to put it here.

Off the top of my head, it was printer profiles, access control, backup and logs that refreshed themselves like this.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Issue has been approved by the bot or manually for further processing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants