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

PERF: delay preset sync until tab completion is accessed #1317

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tangkong
Copy link
Contributor

@tangkong tangkong commented Jan 11, 2025

Description

Delays preset file reading until tab-completion has been attempted. Stashes this information on the device instance itself. This is not the default behavior, and you must opt into this by supplying the optional argument defer_loading to setup_presets_paths

Motivation and Context

Presets have taken a very long time to load recently, and the first place to look is often file i/o. This delays this as long as possible while attempting to preserve the behavior hutch scientists use: tab completion.

This has also been made optional. Both setup_presets_paths and Presets.sync() now take an optional defer_loading argument, that if true will skip the preset data loading step

In a nutshell:

  • the device instance tracks whether a tab-completion has been attempted
    • if it hasn't, it skips any Presets.sync() method call
    • if it has, run Presets.sync() with defer_loading=False (the default)

How Has This Been Tested?

Tests pass

Tested interactively through hutch-python, loading some subset of 559 xcs presets

  • this PR: 7.53s (0.01345s / preset)
  • current master: 16.21s (0.0289s / preset)

There's some variation but I'm not going to do a battery of tests here

Why isn't this just 0 s?

There's still some path access going on in hutch-python, it's just stopping short of actually opening the presets file.

Where Has This Been Documented?

This PR, a stray comment

Pre-merge checklist

  • Code works interactively
  • Code contains descriptive docstrings, including context and API
  • New/changed functions and methods are covered in the test suite where possible
  • Test suite passes locally
  • Test suite passes on GitHub Actions
  • Ran docs/pre-release-notes.sh and created a pre-release documentation page
  • Pre-release docs include context, functional descriptions, and contributors as appropriate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant