Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

parallelizes gossip packets receiver with processing of requests #17647

Merged
merged 2 commits into from
Jun 7, 2021

Conversation

behzadnouri
Copy link
Contributor

@behzadnouri behzadnouri commented Jun 1, 2021

Problem

Gossip packet processing is composed of two stages:

The former does not acquire any locks and so can be parallelized with
the later, allowing better pipelineing properties and smaller latency in
responding to gossip requests or propagating messages.

Summary of Changes

Added a new stage to gossip consuming packets received from the socket,
deserializing, sanitizing and verifying them and then sending them down the
channel for the actual handling of requests/messages.

@behzadnouri behzadnouri force-pushed the gossip-listen branch 5 times, most recently from 5065a58 to 9d49350 Compare June 2, 2021 18:15
@codecov
Copy link

codecov bot commented Jun 2, 2021

Codecov Report

Merging #17647 (a4e6e6b) into master (7f0349b) will decrease coverage by 0.0%.
The diff coverage is 86.8%.

@@            Coverage Diff            @@
##           master   #17647     +/-   ##
=========================================
- Coverage    82.8%    82.7%   -0.1%     
=========================================
  Files         431      431             
  Lines      120590   120629     +39     
=========================================
- Hits        99866    99862      -4     
- Misses      20724    20767     +43     

Gossip packet processing is composed of two stages:
  * The first is consuming packets from the socket, deserializing,
    sanitizing and verifying them:
    https://github.com/solana-labs/solana/blob/7f0349b29/gossip/src/cluster_info.rs#L2510-L2521
  * The second is actually processing the requests/messages:
    https://github.com/solana-labs/solana/blob/7f0349b29/gossip/src/cluster_info.rs#L2585-L2605

The former does not acquire any locks and so can be parallelized with
the later, allowing better pipelineing properties and smaller latency in
responding to gossip requests or propagating messages.
@behzadnouri behzadnouri changed the title parallelizes gossip listen with packets processing parallelizes gossip packets receiver with processing of requests Jun 3, 2021
@behzadnouri behzadnouri requested review from sakridge and carllin June 3, 2021 16:40
@@ -2659,10 +2683,35 @@ impl ClusterInfo {
Ok(())
}

pub fn listen(
pub(crate) fn consume(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: functions in the code base that start threads generally start with start_*_thread, how about start_socket_consume_thread()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

// Consumes packets received from the socket, deserializing, sanitizing and
// verifying them and then sending them down the channel for the actual
// handling of requests/messages.
fn run_consume(
Copy link
Contributor

@carllin carllin Jun 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: rename to run_socket_consume to be more specific, as "consume" is pretty generic

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

}
}
};
let thread_name = String::from("gossip-consume");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "gossip-consume" -> "gossip-socket-consume"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thread names in linux are limited to 15 characters, and everything after the 15th character is trimmed when inspecting running processes from shell, which will make it confusing if I use a longer name here.

@@ -56,11 +56,15 @@ impl GossipService {
1,
);
let (response_sender, response_receiver) = channel();
let t_responder = streamer::responder("gossip", gossip_socket, response_receiver);
let (consume_sender, listen_receiver) = channel();
let t_consume =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit t_consume -> t_socket_consume

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

match self.run_consume(&receiver, &sender, &thread_pool) {
Err(GossipError::RecvTimeoutError(RecvTimeoutError::Disconnected)) => break,
Err(GossipError::RecvTimeoutError(RecvTimeoutError::Timeout)) => (),
Err(err) => error!("gossip consume: {}", err),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, the only other potential error other than the Timeout is Ok(sender.send(packets)?), https://github.com/solana-labs/solana/pull/17647/files#diff-b07406ad1c913d21d39a4163cb34f48c55cef6d472c814419a732f3937ffceddR2631. Hopefully this one doesn't have a chance of being too spammy?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I guess should be fine.

carllin
carllin previously approved these changes Jun 5, 2021
@mergify mergify bot dismissed carllin’s stale review June 7, 2021 17:06

Pull request has been modified.

@behzadnouri behzadnouri merged commit cab30e2 into solana-labs:master Jun 7, 2021
@behzadnouri behzadnouri deleted the gossip-listen branch June 7, 2021 18:36
mergify bot pushed a commit that referenced this pull request Jun 7, 2021
)

Gossip packet processing is composed of two stages:
  * The first is consuming packets from the socket, deserializing,
    sanitizing and verifying them:
    https://github.com/solana-labs/solana/blob/7f0349b29/gossip/src/cluster_info.rs#L2510-L2521
  * The second is actually processing the requests/messages:
    https://github.com/solana-labs/solana/blob/7f0349b29/gossip/src/cluster_info.rs#L2585-L2605

The former does not acquire any locks and so can be parallelized with
the later, allowing better pipelineing properties and smaller latency in
responding to gossip requests or propagating messages.

(cherry picked from commit cab30e2)
mergify bot added a commit that referenced this pull request Jun 7, 2021
) (#17807)

Gossip packet processing is composed of two stages:
  * The first is consuming packets from the socket, deserializing,
    sanitizing and verifying them:
    https://github.com/solana-labs/solana/blob/7f0349b29/gossip/src/cluster_info.rs#L2510-L2521
  * The second is actually processing the requests/messages:
    https://github.com/solana-labs/solana/blob/7f0349b29/gossip/src/cluster_info.rs#L2585-L2605

The former does not acquire any locks and so can be parallelized with
the later, allowing better pipelineing properties and smaller latency in
responding to gossip requests or propagating messages.

(cherry picked from commit cab30e2)

Co-authored-by: behzad nouri <[email protected]>
@brooksprumo brooksprumo mentioned this pull request Aug 23, 2021
mergify bot pushed a commit that referenced this pull request Aug 27, 2021
)

Gossip packet processing is composed of two stages:
  * The first is consuming packets from the socket, deserializing,
    sanitizing and verifying them:
    https://github.com/solana-labs/solana/blob/7f0349b29/gossip/src/cluster_info.rs#L2510-L2521
  * The second is actually processing the requests/messages:
    https://github.com/solana-labs/solana/blob/7f0349b29/gossip/src/cluster_info.rs#L2585-L2605

The former does not acquire any locks and so can be parallelized with
the later, allowing better pipelineing properties and smaller latency in
responding to gossip requests or propagating messages.

(cherry picked from commit cab30e2)

# Conflicts:
#	core/src/cluster_info.rs
@behzadnouri behzadnouri added v1.6 and removed v1.6 labels Aug 27, 2021
mergify bot added a commit that referenced this pull request Aug 27, 2021
…kport #17647) (#19474)

* parallelizes gossip packets receiver with processing of requests (#17647)

Gossip packet processing is composed of two stages:
  * The first is consuming packets from the socket, deserializing,
    sanitizing and verifying them:
    https://github.com/solana-labs/solana/blob/7f0349b29/gossip/src/cluster_info.rs#L2510-L2521
  * The second is actually processing the requests/messages:
    https://github.com/solana-labs/solana/blob/7f0349b29/gossip/src/cluster_info.rs#L2585-L2605

The former does not acquire any locks and so can be parallelized with
the later, allowing better pipelineing properties and smaller latency in
responding to gossip requests or propagating messages.

(cherry picked from commit cab30e2)

# Conflicts:
#	core/src/cluster_info.rs

* removes backport merge conflicts

Co-authored-by: behzad nouri <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants