Skip to content

Commit 06a461a

Browse files
authored
SumSpectra reserve EventList based on Event Type (#39586)
### Description of work Similar to #39348, This PR aims to fix a performance issue where EventList::operator+=() was being used inefficiently. This caused Mantid to hang due to repeated memory reallocation as each EventList was appended. This fix improves performance by correctly preallocating memory based on the eventType of each EventList, ensuring the appropriate storage structure is reserved up front. Relates to [EWM12012](https://ornlrse.clm.ibmcloud.com/ccm/web/projects/Neutron%20Data%20Project%20%28Change%20Management%29#action=com.ibm.team.workitem.viewWorkItem&id=12012) --- ### Reviewer Please comment on the points listed below ([full description](http://developer.mantidproject.org/ReviewingAPullRequest.html)). **Your comments will be used as part of the gatekeeper process, so please comment clearly on what you have checked during your review.** If changes are made to the PR during the review process then your final comment will be the most important for gatekeepers. In this comment you should make it clear why any earlier review is still valid, or confirm that all requested changes have been addressed. #### Code Review - Is the code of an acceptable quality? - Does the code conform to the [coding standards](http://developer.mantidproject.org/Standards/)? - Are the unit tests small and test the class in isolation? - If there is GUI work does it follow the [GUI standards](http://developer.mantidproject.org/Standards/GUIStandards.html)? - If there are changes in the release notes then do they describe the changes appropriately? - Do the release notes conform to the [release notes guide](https://developer.mantidproject.org/Standards/ReleaseNotesGuide.html)? #### Functional Tests - Do changes function as described? Add comments below that describe the tests performed? - Do the changes handle unexpected situations, e.g. bad input? - Has the relevant (user and developer) documentation been added/updated? Does everything look good? Mark the review as **Approve**. A member of `@mantidproject/gatekeepers` will take care of it. ### Gatekeeper If you need to request changes to a PR then please add a comment and set the review status to "Request changes". This will stop the PR from showing up in the list for other gatekeepers.
1 parent f656c1e commit 06a461a

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

Framework/Algorithms/src/SumSpectra.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ void SumSpectra::execEvent(const MatrixWorkspace_sptr &outputWorkspace, Progress
583583
}
584584
numOutputEvents += inputWorkspace->getSpectrum(i).getNumberEvents();
585585
}
586-
586+
outputEL.switchTo(inputWorkspace->getSpectrum(0).getEventType());
587587
outputEL.reserve(numOutputEvents);
588588

589589
// Loop over spectra
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fix an issue where :ref:`SumSpectra <algm-SumSpectra>` would freeze when on large datasets when adding EventList to the Output Workspace if the Event Type was weighted.

0 commit comments

Comments
 (0)