perf: remove unnecessary clones from multitopic producer#380
perf: remove unnecessary clones from multitopic producer#380BewareMyPower merged 1 commit intostreamnative:masterfrom
Conversation
43ac093 to
6ed71e8
Compare
| .client | ||
| .producer() | ||
| .with_topic(entry.key()) | ||
| .with_options(self.options.clone()); |
There was a problem hiding this comment.
The multi-topic producer should probably share options with the inner producers to remove this clone. Would you be open to me referencing the the producer options from the multi-topic producer instead of cloning for each topic in the multi-producer? I'd need to explore how to do that without changing the single-topic producer too much
There was a problem hiding this comment.
IMO, the core optimization of this PR is reduce two queries on a tree map (contains_key and get_mut) to one (entry) on the hot path send_non_blocking. But the case when the producer is absent should not be frequent, cloning the options is acceptable.
There was a problem hiding this comment.
And yes, sharing the same options makes sense.
Small improvement to
send_non_blocking()on multi-topic producers to use the entry API. Removes the need to clone the topic name and get the producer after inserting it. Additional removal of an unnecessary clone on theconnect()method