Skip to content

Commit

Permalink
Reflection table performance improvement (dials#2718)
Browse files Browse the repository at this point in the history
Eliminate a double loop in selections from reflection tables. Speedup of 12 min per call
for a table containing 165k experiment identifiers.

Co-authored-by: David Mittan-Moreau <dwmoreau@lbl.gov>
Co-authored-by: Aaron Brewster <asbrewster@lbl.gov>
  • Loading branch information
3 people authored Aug 9, 2024
1 parent fd79852 commit a2f8f71
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
3 changes: 3 additions & 0 deletions newsfragments/2718.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Performance improvement for selections from large reflection tables. For a
table containing 165k experiment identifiers the speedup is 1000x (12 minutes
per call).
11 changes: 4 additions & 7 deletions src/dials/array_family/boost_python/reflection_table_suite.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,9 @@ namespace dials { namespace af { namespace boost_python {
// Copy across identifiers for ids in new table
typedef typename T::experiment_map_type::const_iterator const_iterator;
for (std::set<int>::iterator i = new_ids.begin(); i != new_ids.end(); ++i) {
for (const_iterator it = self.experiment_identifiers()->begin();
it != self.experiment_identifiers()->end();
++it) {
if (it->first == *i) {
(*new_table.experiment_identifiers())[it->first] = it->second;
}
const_iterator found = self.experiment_identifiers()->find(*i);
if (found != self.experiment_identifiers()->end()) {
(*new_table.experiment_identifiers())[found->first] = found->second;
}
}
}
Expand Down Expand Up @@ -262,4 +259,4 @@ namespace dials { namespace af { namespace boost_python {

}}}} // namespace dials::af::boost_python::reflection_table_suite

#endif // DIALS_ARRAY_FAMILY_BOOST_PYTHON_REFLECTION_TABLE_SUITE_H
#endif // DIALS_ARRAY_FAMILY_BOOST_PYTHON_REFLECTION_TABLE_SUITE_H

0 comments on commit a2f8f71

Please sign in to comment.