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

Prevent computing full document content highlight per block and only compute current block content for performance #246

Merged
merged 1 commit into from
May 28, 2024

Conversation

dalthviz
Copy link
Contributor

Related with napari/napari#6845

Current code computes the full document highlight for each document block/paragraph causing freezes as soon the document content starts to get a little bit long. To reproduce, you can run the examples/code_highlight.py, copy and paste the widget text content multiple times (selecting the full content to do a new paste increases the chance to stumble with a freeze in a shorter amount of time). So something like:

highlight

This PR tries to prevent/improve the situation by only computing the current block content/text highlight data (not sure if there is a better approach so happy to give a check to any other ideas!). Doing a similar check with the example content copy and paste operations with the changes in this PR:

highlight_perf

@dalthviz dalthviz changed the title Prevent computing full document content highlight and only compute current block content for performance Prevent computing full document content highlight per block and only compute current block content for performance May 27, 2024
Copy link

codecov bot commented May 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.07%. Comparing base (0ec5cd3) to head (f785fe3).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #246      +/-   ##
==========================================
- Coverage   87.12%   87.07%   -0.06%     
==========================================
  Files          46       46              
  Lines        3403     3397       -6     
==========================================
- Hits         2965     2958       -7     
- Misses        438      439       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tlambert03 tlambert03 requested a review from Czaki May 27, 2024 19:41
@tlambert03
Copy link
Member

@Czaki, since this is your object, would appreciate your review

@Czaki
Copy link
Contributor

Czaki commented May 28, 2024

This change provides a significant performance boost and I do not see downsides of these changes.

Test failures look unrelated.

@tlambert03 tlambert03 merged commit 7b1aefd into pyapp-kit:main May 28, 2024
44 of 48 checks passed
@tlambert03 tlambert03 added the perf performance improvements label Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf performance improvements
Development

Successfully merging this pull request may close these issues.

3 participants