Skip to content

Improve implementation of flags cloneAndReplace

This MR simplifies the implementation of the cloneAndReplace. Before each operation was basically copying large dictionary of the flags. Now the "rewiring" is remembered and used when constructing the flag address. The flags are effiectively only shallow copied irrespectively if they are locked or not (btw I do not think we have usecase for cloneAndReplace for unlocked flags). I have measured the time spent on this operation in code like:

newflags = flags.cloneAndReplace("Tracking.ActiveConfig", "Tracking.LowPtPass")
# now access some flags to makre sure slower reading is not spoiling the benefit of faster c&r
vals = newflags.Tracking.ActiveConfig.extension, newflags.Tracking.ActiveConfig.maxSctHoles, newflags.Tracking.ActiveConfig.useSeedFilter, newflags.Tracking.ActiveConfig.radMax

newflags = flags.cloneAndReplace("Tracking.ActiveConfig", "Tracking.LowPtRoIPass")

The time (on 4 such operations) changed from 0.04s to 0.014 (about 3times faster).

The implementation will also be very easy to modify if we will like to maintain the access to rewired flags that @jmasik and @sutt need. Tagging @tstreble @tadej @wlampl @fwinkl

Edited by Thomas Strebler

Merge request reports