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 top-level import speed with deferred imports #2394

Merged
merged 2 commits into from
Dec 2, 2024
Merged

Conversation

sbailey
Copy link
Contributor

@sbailey sbailey commented Oct 15, 2024

This PR addresses several import speed issues identified in #2379, especially for desispec.io.

desispec.io: deferring imports of specutils, speclite.filters, and desispec.preproc improves "import desispec.io" from 4.1 seconds to 1.3 seconds (best of 5, pwd on scratch). The remaining time is dominated by importing astropy.table (1.0 sec), which would be messy to defer everywhere.

desispec.tsnr: deferring import astropy.convolution improves "import desispec.tsnr" from 2.9 to 2.3 sec. Remaining big imports are astropy.table and astropy.coordinates via desiutil.dust.

desispec.pixgroup: removing unused import healpix improves "import desispec.pixgroup" from 3.7 to 3.15 sec. Remaining big imports are desispec.tsnr (could be deferred, though this is a bit messy since TSNR is re-calculated on-the-fly if columns are missing from older data)

@coveralls
Copy link

Coverage Status

coverage: 30.186% (-0.006%) from 30.192%
when pulling 5fabf40 on import_speed
into 05bcd76 on main.

@sbailey sbailey requested a review from akremin December 2, 2024 23:26
Copy link
Member

@akremin akremin left a comment

Choose a reason for hiding this comment

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

Thanks, all these changes look good to me and I checked that there are no missing imports in any functions.

@akremin akremin merged commit bc58825 into main Dec 2, 2024
26 checks passed
@akremin akremin deleted the import_speed branch December 2, 2024 23:46
@sbailey
Copy link
Contributor Author

sbailey commented Dec 2, 2024

For the record: I also ran a mini-prod with this branch in /global/cfs/cdirs/desi/users/sjbailey/spectro/redux/mini-pr2394 with jobs ccdcalib, arc, psfnight, flat, nightlyflat, tilenight, cumulative ztile, zpix, plus desi_tsnr_afterburner and desi_zcatalog. I think that covers everything touched by the deferred imports in this PR, e.g. to make sure that I didn't defer too much.

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.

3 participants