Conversation
src/topology/fanout.rs
Outdated
| } else { | ||
| while self.i < self.sinks.len() { | ||
| let (_name, sink) = &mut self.sinks[self.i]; | ||
| match sink.start_send(item.clone()) { |
There was a problem hiding this comment.
This might be completely wrong since I'm just a lowly Elixir engineer 😄, but could you gain the same performance benefit by only cloning on the second and later sinks? This has the benefit of not cloning on the first sink when there are multiple.
There was a problem hiding this comment.
Pretty much! I just pushed a change that doesn't clone on the last sink, which is basically the same thing.
I'm ok with this as long as the end result is the same. I can see this biting us down the road again, but I'm hoping we'll integrate benchmark results into releases before then. |
| .map_err(|e| error!("failed to accept socket; error = {}", e)) | ||
| .for_each(move |socket| { | ||
| let peer_addr = socket.peer_addr().ok().map(|s| s.ip()); | ||
| let peer_addr = socket.peer_addr().ok().map(|s| s.ip().to_string()); |
There was a problem hiding this comment.
I wonder if we can do better here and use something like https://doc.rust-lang.org/std/net/struct.Ipv4Addr.html#method.octets and https://doc.rust-lang.org/std/net/struct.Ipv6Addr.html#method.segments this should reduce the overhead in checking the utf8?
There was a problem hiding this comment.
I'm not worried about this because it only happens when a new connection is established, not for every record.
|
For the |
|
Luke and I talked about this as an improvement maybe now is the right time to do this? |
|
@LucioFranco I'm pretty sure what we discussed was using shared values within the hashmap, which we're already doing with @michaelfairley Using something like |
|
I forgot to point out that this break's splunk's usage of the host field: https://github.com/timberio/vector/blob/43f207c90564b8363b8784096e2e8a9c7555bd95/src/sinks/splunk.rs#L83 |
|
I actually think that's a good reason host should be a declared field. If we were using the |
|
@michaelfairley Good catch. Opened #276 to address that. @binarylogic Yeah, now if we remove the |
These changes together seem to get us a ~2x performance increase on the TCP -> blackhole use case we've been testing. Most are pretty straightforward.
The one that might be controversial is moving
hostback to being an optional field onRecord. Reasons I think it's a good idea:to_string, there was significant cost to theHashMap::insertbecause it was always allocating to resize from 0 -> 1.hostout of the map. That way we can check for keys in the map to determine if a record went through a structuring transform.That said, I'm definitely open to any feedback on any of these changes.
Tagging #268