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

improve laggy subset finalization #3175

Merged
merged 4 commits into from
Sep 5, 2024

Conversation

kecnry
Copy link
Member

@kecnry kecnry commented Aug 29, 2024

Description

This pull request limits the updates to subset_selected_changed_callback (originally introduced in #2939) to only trigger for subset update messages corresponding to the currently selected subset (and only when the subset state has been changed, not color, etc) and also minimizes spectral extraction calls when subset_select.items are changed to only affect the selected entry.

Fixes #3164

Change log entry

  • Is a change log needed? If yes, is it added to CHANGES.rst? If you want to avoid merge conflicts,
    list the proposed change log here for review and add to CHANGES.rst before merge. If no, maintainer
    should add a no-changelog-entry-needed label.

Checklist for package maintainer(s)

This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.

  • Are two approvals required? Branch protection rule does not check for the second approval. If a second approval is not necessary, please apply the trivial label.
  • Do the proposed changes actually accomplish desired goals? Also manually run the affected example notebooks, if necessary.
  • Do the proposed changes follow the STScI Style Guides?
  • Are tests added/updated as required? If so, do they follow the STScI Style Guides?
  • Are docs added/updated as required? If so, do they follow the STScI Style Guides?
  • Did the CI pass? If not, are the failures related?
  • Is a milestone set? Set this to bugfix milestone if this is a bug fix and needs to be released ASAP; otherwise, set this to the next major release milestone. Bugfix milestone also needs an accompanying backport label.
  • After merge, any internal documentations need updating (e.g., JIRA, Innerspace)?

@kecnry kecnry added the no-changelog-entry-needed changelog bot directive label Aug 29, 2024
@kecnry kecnry added this to the 4.0 milestone Aug 29, 2024
@kecnry kecnry marked this pull request as ready for review August 29, 2024 12:10
Copy link

codecov bot commented Aug 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.37%. Comparing base (69e31b7) to head (7b6b95d).
Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3175      +/-   ##
==========================================
- Coverage   88.42%   88.37%   -0.05%     
==========================================
  Files         122      122              
  Lines       18267    18278      +11     
==========================================
+ Hits        16153    16154       +1     
- Misses       2114     2124      +10     

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

@pllim pllim added bug Something isn't working performance Performance related Affects-dev changelog bot directive labels Aug 29, 2024
@kecnry kecnry force-pushed the fix-subset-selected-callback branch from 56d5bb8 to 0e9c1ca Compare August 29, 2024 13:58
@kecnry kecnry force-pushed the fix-subset-selected-callback branch from 2191ae0 to 7b6b95d Compare August 29, 2024 15:57
Comment on lines -617 to +624
child_layer_icons[child_layer] = f'{parent_icon}{i}'
if child_layer not in self.state.layer_icons:
child_layer_icons[child_layer] = f'{parent_icon}{i}'

self.state.layer_icons = {
**self.state.layer_icons,
**child_layer_icons
}
if child_layer_icons:
self.state.layer_icons = {
**self.state.layer_icons,
**child_layer_icons
}
Copy link
Member Author

Choose a reason for hiding this comment

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

FYI: @bmorris3 - does this seem reasonable? I'm trying to avoid an update to the state again if no new child layers are added.

@kecnry kecnry changed the title fix laggy subset finalization improve laggy subset finalization Aug 29, 2024
Copy link
Contributor

@javerbukh javerbukh left a comment

Choose a reason for hiding this comment

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

I think I notice a marginal improvement on my windows PC and the code looks reasonable so I will approve. Looking forward to more optimization in this direction!

@rosteen
Copy link
Collaborator

rosteen commented Sep 3, 2024

I found this to be a very minor improvement, but this apparently isn't the source of most of the (millions of) calls to startswith that I was seeing. I think we can get it in, but let's not close the issue that started it (I'll have to remake that issue, it got deleted).

Copy link
Collaborator

@rosteen rosteen left a comment

Choose a reason for hiding this comment

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

Approved, but please don't close until @pllim has remade the deleted corresponding issue.

@kecnry
Copy link
Member Author

kecnry commented Sep 5, 2024

I won't have this close #3181 since it doesn't fully address the lag (although it should address the unnecessary calls to spectral extraction during the subset creation process).

@kecnry kecnry merged commit 8b3f3a1 into spacetelescope:main Sep 5, 2024
24 of 25 checks passed
@kecnry kecnry deleted the fix-subset-selected-callback branch September 5, 2024 18:09
cshanahan1 pushed a commit to cshanahan1/jdaviz that referenced this pull request Sep 9, 2024
* only call subset_selected_changed_callback for matching subset updates
* optimize handling subset_state changes
* prevent unnecessary state-update
* avoid (some cases of) startswith since can be expensive on some machines
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Affects-dev changelog bot directive bug Something isn't working no-changelog-entry-needed changelog bot directive performance Performance related Ready for final review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants