Repository navigation
ITC perf improvement, reuse the current bin results - #2443
Merged
Merged
Conversation
Convolving a spectrum with a transmission element evaluated getY(double) on the element for every point: an interface call, two range checks, a bin lookup and a fresh slope each time, 39 percent of the remaining time in the profile. DefaultArraySpectrum.Interpolator keeps the current bin and slope between calls and evaluates the same expression with the same operands, so results are bit-identical while consecutive points in one bin skip the lookup. TransmissionElement.visit and Instrument.addBackground use it. Three alternating harness runs: 130 ms without, 104 ms with, every case faster, allocation and golden outputs unchanged.
|
This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again. |
swalker2m
approved these changes
Nov 2, 2026
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 Uni
7043
code 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.
Applying a transmission element to a spectrum called
getY(double)once per point. Each call made an interface call, ran two range checks, looked up the bin and computed a new slope. This is correct but it has a cost identified while profilingThis PR adds
DefaultArraySpectrum.Interpolator, which keeps the current bin and slope between calls. When the wavelengths come in increasing order, consecutive points that fall in the same bin skip the lookup.TransmissionElement.visitandInstrument.addBackgrounduse the interpolator when the spectrum is aDefaultArraySpectrum. Other spectrum types keep the oldgetYpath.at(x)uses the same expression asgetY, with the same operands, so results are bit-identical. Values outside the range still return 0.Results measured on some test calculations