Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Profile code #22

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Profile code #22

wants to merge 3 commits into from

Conversation

gdanezis
Copy link
Collaborator

@gdanezis gdanezis commented Feb 17, 2021

  • Added profile module
  • Annotated task launch to use the profiler
  • Added async_profile script to make pretty graphs

The profiler requires the package graphviz and is used as follows:

$ fab local # (with debug=True)
$ python async_profile.py logs/node-0.log
$ dot -Tpng parentgraph.dot > parentgraph.png

@asonnino asonnino self-requested a review February 17, 2021 19:59
Copy link
Owner

@asonnino asonnino left a comment

Choose a reason for hiding this comment

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

I updated some of the tasks' names to better reflect the structure of the code.

@@ -36,12 +40,12 @@ impl Consensus {
x
})?;
let network_receiver = NetReceiver::new(address, tx_core.clone());
tokio::spawn(async move {
pspawn!("Net-Receiver", {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
pspawn!("Net-Receiver", {
pspawn!("Consensus-Receiver", {

network_receiver.run().await;
});

let mut network_sender = NetSender::new(rx_network);
tokio::spawn(async move {
pspawn!("Net-Sender", {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
pspawn!("Net-Sender", {
pspawn!("Consensus-Sender", {

@@ -22,7 +25,7 @@ impl<Mempool: 'static + NodeMempool> MempoolDriver<Mempool> {
pub fn new(mempool: Mempool, core_channel: Sender<CoreMessage>, store: Store) -> Self {
let (tx_inner, mut rx_inner): (_, Receiver<DriverMessage>) = channel(1000);
let mut waiting = FuturesUnordered::new();
tokio::spawn(async move {
pspawn!("Mempool", {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
pspawn!("Mempool", {
pspawn!("Mempool-Driver", {

@@ -45,7 +48,7 @@ impl SimpleMempool {
})?;

let front = Front::new(address, tx_client);
tokio::spawn(async move {
pspawn!("Simple-Mempool-Front", {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
pspawn!("Simple-Mempool-Front", {
pspawn!("Mempool-Txs-Receiver", {

@@ -38,7 +41,7 @@ impl Front {
}

async fn spawn_worker(socket: TcpStream, peer: SocketAddr, deliver: Sender<Transaction>) {
tokio::spawn(async move {
pspawn!("Front-Worker", {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
pspawn!("Front-Worker", {
pspawn!("Txs-Receiver-Worker", {

@@ -55,12 +58,12 @@ impl SimpleMempool {
x
})?;
let network_receiver = NetReceiver::new(address, tx_core);
tokio::spawn(async move {
pspawn!("Simple-Mempool-Receiver", {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
pspawn!("Simple-Mempool-Receiver", {
pspawn!("Mempool-Receiver", {

network_receiver.run().await;
});

let mut network_sender = NetSender::new(rx_network);
tokio::spawn(async move {
pspawn!("Simple-Mempool-Sender", {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
pspawn!("Simple-Mempool-Sender", {
pspawn!("Mempool-Sender", {

@@ -76,7 +79,7 @@ impl SimpleMempool {
/* client_channel */ rx_client,
/* network_channel */ tx_network,
);
tokio::spawn(async move {
pspawn!("Core-Runner", {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
pspawn!("Core-Runner", {
pspawn!("Mempool-Core", {

@@ -60,7 +63,7 @@ impl NetSender {
async fn spawn_worker(address: SocketAddr) -> Sender<Bytes> {
// Each worker handle a TCP connection with on address.
let (tx, mut rx) = channel(1000);
tokio::spawn(async move {
pspawn!(format!("Net-Sender-{:?}", address), {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
pspawn!(format!("Net-Sender-{:?}", address), {
pspawn!(format!("Sender-Worker-{:?}", address), {

@@ -118,7 +121,7 @@ impl<Message: 'static + Send + DeserializeOwned + Debug> NetReceiver<Message> {
}

async fn spawn_worker(socket: TcpStream, peer: SocketAddr, deliver: Sender<Message>) {
tokio::spawn(async move {
pspawn!(format!("Net-Receiver-{:?}", peer), {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
pspawn!(format!("Net-Receiver-{:?}", peer), {
pspawn!(format!("Receiver-Worker-{:?}", peer), {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants