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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clicking View Traceback in the status notification (GUI) is *really* slow #6845

Open
psobolewskiPhD opened this issue Apr 15, 2024 · 3 comments
Labels
bug Something isn't working performance Relates to performance

Comments

@psobolewskiPhD
Copy link
Member

馃悰 Bug Report

If you get a traceback while using the GUI you get the small notification about it.
It has View Traceback button that brings up a nicely formatted traceback you can copy paste.
However, on my machine, from click to getting that window is ~1 min. with everything blocking.
This is really aweful!

馃挕 Steps to Reproduce

Run napari from terminal.
Trigger traceback, e.g. drag-n-drop a folder that doesn't contain images.

馃挕 Expected Behavior

The window should spawn within a few seconds at most.

馃寧 Environment

napari: 0.4.19.post1
Platform: macOS-14.4.1-arm64-arm-64bit
System: MacOS 14.4.1
Python: 3.11.7 | packaged by conda-forge | (main, Dec 23 2023, 14:38:07) [Clang 16.0.6 ]
Qt: 5.15.8
PyQt5: 5.15.9
NumPy: 1.26.3
SciPy: 1.12.0
Dask: 2024.1.1
VisPy: 0.14.1
magicgui: 0.8.1
superqt: 0.6.1
in-n-out: 0.1.9
app-model: 0.2.4
npe2: 0.7.4

OpenGL:

  • GL version: 2.1 Metal - 88
  • MAX_TEXTURE_SIZE: 16384

Screens:

  • screen 1: resolution 2056x1329, scale 2.0
  • screen 2: resolution 2560x1440, scale 1.0

Settings path:

  • /Users/sobolp/Library/Application Support/napari/napari-419_9f9c3b1d4cb071ffa9c3954dc49db19675ab479f/settings.yaml

馃挕 Additional Context

No response

@psobolewskiPhD psobolewskiPhD added bug Something isn't working performance Relates to performance labels Apr 15, 2024
@dalthviz
Copy link
Member

Hi there, just in case, I gave the related logic a check and I think the performance problem comes from the highlight data being computed for the full traceback multiple times (once per content block/paragraph) here:

def highlightBlock(self, text):
cb = self.currentBlock()
p = cb.position()
text = self.document().toPlainText() + '\n'
highlight(text, self.lexer, self.formatter)

Changing the logic to do the highlight computation only once seems like helps. So changing things to look something like a6df139

A preview:

traceback

Happy to open a PR if that makes sense :)

@psobolewskiPhD
Copy link
Member Author

I think that makes sense, @Czaki any thoughts? you wrote it 馃槈
Also, this looks to have been up-streamed to superqt:
https://github.com/pyapp-kit/superqt/blob/0ec5cd3a2f967f04f0240e2421a6fd2f2f7fcf25/src/superqt/utils/_code_syntax_highlight.py

Maybe we should fix there and then use superqt version in napari?

@Czaki
Copy link
Collaborator

Czaki commented May 24, 2024

Maybe we should fix there and then use superqt version in napari?

I think that this will be best solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working performance Relates to performance
Projects
None yet
Development

No branches or pull requests

3 participants