Problem
OffsetSnapshot::get_opt() in bridge-core/src/snapshot/mod.rs does linear search through the vector. For large snapshots with many consumer groups/topics/partitions, this is O(n) per lookup.
Suggestion
Use a HashMap<(ConsumerGroup, Topic, Partition), Offset> for O(1) lookups instead of iterating through the vector.
// Current: O(n) linear search
pub fn get_opt(&self, group: &str, topic: &str, partition: i32) -> Option<&OffsetRecord> {
self.0.iter().find(|r| r.consumer_group == group && r.topic == topic && r.partition == partition)
}
// Suggested: O(1) HashMap lookup
Impact
Improves performance for migrations involving many consumer groups or topics.
Problem
OffsetSnapshot::get_opt()inbridge-core/src/snapshot/mod.rsdoes linear search through the vector. For large snapshots with many consumer groups/topics/partitions, this is O(n) per lookup.Suggestion
Use a
HashMap<(ConsumerGroup, Topic, Partition), Offset>for O(1) lookups instead of iterating through the vector.Impact
Improves performance for migrations involving many consumer groups or topics.