Improve performance of HEALPix to rectangular by skipping calculation of debug string if it will not be logged - #3352
Open
pleasant-menlo wants to merge 1 commit into
Conversation
…alue_from_healpix_map_n_subdivisions only if the string will be logged
jtniehof
reviewed
Jul 27, 2026
Comment on lines
+1807
to
+1808
| f" Mean pixel value at Number of subdivisions: %s: " | ||
| f"array of shape %s: %s", num_subdivisions, mean_pixel_value.shape, mean_pixel_value |
Collaborator
There was a problem hiding this comment.
Should this still be an f-string since the only string interpolation is being done within the logger, using the %s and other arguments?
Collaborator
There was a problem hiding this comment.
Also precommit ruff complains line 1808 is too long, but I presume this is not news :)
Collaborator
|
For context, this is a step towards addressing IMAP-Science-Operations-Center/imap_L3_processing#142 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change Summary
Overview
When profiling the HEALPix to rectangular conversion, we found a debug log that was taking a significant amount of time.
imap_processing/imap_processing/ena_maps/ena_maps.py
Lines 1806 to 1809 in 7c51269
Since this uses f-strings, it always calculates the string (including stringifying the contents of the subdivided
mean_pixel_valuedata array), even if the logging level does not include debug logs.We replaced the f-strings in the logger.debug call with %s placeholders and passed the strings in as parameters to avoid building the log string at non-debug log levels.