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

Disable buffer swapping #5741

Merged
merged 6 commits into from Apr 22, 2023
Merged

Disable buffer swapping #5741

merged 6 commits into from Apr 22, 2023

Conversation

brisvag
Copy link
Contributor

@brisvag brisvag commented Apr 18, 2023

Fixes/Closes

Closes #5734.

Description

This change drastically improves performance on some hardware by sacrificing some quality (tearing is more likely). However, several people tested it and didn't notice any appreciable degradation of the rendering, so it seems like a worthwile exchange. See #5734 for more details.

We might be able to fix this on the vispy side, but for now this works well on the napari side.

Type of change

  • Bug-fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

cc @ksofiyuk

@Czaki
Copy link
Collaborator

Czaki commented Apr 18, 2023

Could we control this using environment variable?

@codecov
Copy link

codecov bot commented Apr 18, 2023

Codecov Report

Merging #5741 (cfe9bf3) into main (95356e4) will decrease coverage by 1.45%.
The diff coverage is 100.00%.

❗ Current head cfe9bf3 differs from pull request most recent head 3770faf. Consider uploading reports for the commit 3770faf to get more accurate results

@@            Coverage Diff             @@
##             main    #5741      +/-   ##
==========================================
- Coverage   89.83%   88.39%   -1.45%     
==========================================
  Files         608      608              
  Lines       51881    51882       +1     
==========================================
- Hits        46608    45861     -747     
- Misses       5273     6021     +748     
Impacted Files Coverage Δ
napari/_qt/qt_viewer.py 79.23% <ø> (-0.39%) ⬇️
napari/settings/_experimental.py 100.00% <100.00%> (ø)

... and 39 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@brisvag
Copy link
Contributor Author

brisvag commented Apr 18, 2023

Could we control this using environment variable?

I would make it disabled by default in that case, though. Can you point me to where the env variable stuff is normally set?

@Czaki
Copy link
Collaborator

Czaki commented Apr 18, 2023

The user could set it in his .bashrc, .zshrc .profile, etc

@brisvag
Copy link
Contributor Author

brisvag commented Apr 18, 2023

I meant where in the napari code we read all the env variables and store them for later usage in the code :P Or would you just read it when the canvas is created?

@Czaki
Copy link
Collaborator

Czaki commented Apr 18, 2023

I do not know the such place.

I prefer using it when creating Canvas. It is rare enough for me not to think about performance.

@brisvag
Copy link
Contributor Author

brisvag commented Apr 18, 2023

Something like this? I suppose this should be somewhere in the docs as well.

@Czaki
Copy link
Collaborator

Czaki commented Apr 18, 2023

Yes. This needs to be added to docs.

@brisvag
Copy link
Contributor Author

brisvag commented Apr 18, 2023

I see some mentions of environment variable regarding rendering in docs/guides/rendering.md, as well as docs/guides/rendering-explanation.md. I suppose one of those places could work? Opinions from the docs experts? @melissawm @psobolewskiPhD

napari/_qt/qt_viewer.py Outdated Show resolved Hide resolved
@Czaki
Copy link
Collaborator

Czaki commented Apr 18, 2023

I prefer to have a single place with list of all Environment variables use by napari. Best, next to settings.

brisvag and others added 2 commits April 18, 2023 17:09
Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com>
@psobolewskiPhD
Copy link
Member

psobolewskiPhD commented Apr 18, 2023

I think this section is prolly the best? But I think the whole thing at some point needs to be rewritten—I think it's mostly autogenerated?
https://napari.org/stable/guides/preferences.html
I mean you could also add this experimental preferences pane, like the async stuff? 🤷‍♂️

@github-actions github-actions bot added the preferences Issues relating to the creation of new preference fields/panels label Apr 19, 2023
@brisvag
Copy link
Contributor Author

brisvag commented Apr 19, 2023

I moved it to the experimental settings. Now it works both from there and as a env variable!

@brisvag
Copy link
Contributor Author

brisvag commented Apr 19, 2023

I think it's mostly autogenerated?

Yep, so this should get added automatically now that it's a preference.

Maybe experimental is not quite the right place (advanced? :P) but for now I think it works.

@brisvag brisvag added performance Relates to performance bugfix PR with bugfix labels Apr 19, 2023
@brisvag brisvag removed the bugfix PR with bugfix label Apr 19, 2023
@ksofiyuk
Copy link
Contributor

I've tested it, works great for me, @brisvag thank you for the fix!

@brisvag brisvag requested a review from Czaki April 19, 2023 19:05
Copy link
Member

@psobolewskiPhD psobolewskiPhD left a comment

Choose a reason for hiding this comment

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

I can't see any performance difference nor any visual effect, but I like the implementation.
I wonder whether it should be true or false by default, given that the existing behavior is true.

@brisvag
Copy link
Contributor Author

brisvag commented Apr 19, 2023

My reasoning was: it's more likely that a new user affected by the bug will simply think "oh well napari has terrible performance, bye" rather than opening an issue or testing experimental settings. And the cost seems basically zero otherwise 🤷

Copy link
Contributor

@alisterburt alisterburt left a comment

Choose a reason for hiding this comment

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

+1 on False as the new default - if we get reports of tearing we can reevaluate

@alisterburt alisterburt merged commit 3a29859 into napari:main Apr 22, 2023
27 of 28 checks passed
@Czaki Czaki mentioned this pull request Jun 7, 2023
@Czaki Czaki added this to the 0.4.18 milestone Jun 16, 2023
Czaki added a commit that referenced this pull request Jun 19, 2023
# Fixes/Closes
Closes #5734.

# Description
This change drastically improves performance on some hardware by
sacrificing some quality (tearing is more likely). However, several
people tested it and didn't notice any appreciable degradation of the
rendering, so it seems like a worthwile exchange. See #5734 for more
details.

We might be able to fix this on the vispy side, but for now this works
well on the napari side.

## Type of change
<!-- Please delete options that are not relevant. -->
- [x] Bug-fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update

cc @ksofiyuk

---------

Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Czaki added a commit that referenced this pull request Jun 21, 2023
# Fixes/Closes
Closes #5734.

# Description
This change drastically improves performance on some hardware by
sacrificing some quality (tearing is more likely). However, several
people tested it and didn't notice any appreciable degradation of the
rendering, so it seems like a worthwile exchange. See #5734 for more
details.

We might be able to fix this on the vispy side, but for now this works
well on the napari side.

## Type of change
<!-- Please delete options that are not relevant. -->
- [x] Bug-fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update

cc @ksofiyuk

---------

Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Czaki added a commit that referenced this pull request Jun 21, 2023
# Fixes/Closes
Closes #5734.

# Description
This change drastically improves performance on some hardware by
sacrificing some quality (tearing is more likely). However, several
people tested it and didn't notice any appreciable degradation of the
rendering, so it seems like a worthwile exchange. See #5734 for more
details.

We might be able to fix this on the vispy side, but for now this works
well on the napari side.

## Type of change
<!-- Please delete options that are not relevant. -->
- [x] Bug-fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update

cc @ksofiyuk

---------

Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Czaki added a commit that referenced this pull request Jun 21, 2023
# Fixes/Closes
Closes #5734.

# Description
This change drastically improves performance on some hardware by
sacrificing some quality (tearing is more likely). However, several
people tested it and didn't notice any appreciable degradation of the
rendering, so it seems like a worthwile exchange. See #5734 for more
details.

We might be able to fix this on the vispy side, but for now this works
well on the napari side.

## Type of change
<!-- Please delete options that are not relevant. -->
- [x] Bug-fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update

cc @ksofiyuk

---------

Co-authored-by: Grzegorz Bokota <bokota+github@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement performance Relates to performance preferences Issues relating to the creation of new preference fields/panels qt Relates to qt
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Very slow rendering when using autoswap=True in the VisPy Canvas
5 participants