Skip to content

Commit

Permalink
fix: a few optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
BastienFaivre committed Jan 20, 2025
1 parent cf7b0fc commit 2939d98
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 5 deletions.
8 changes: 7 additions & 1 deletion benchmark/code/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ use crate::config::{Config, Protocol};

pub(crate) const GOSSIPSUB_TOPIC_STR: &str = "benchmark";

const MAX_TRANSMIT_SIZE: usize = 4 * 1024 * 1024; // 4 MiB

#[cfg(feature = "debug")]
#[derive(Debug)]
pub(crate) enum NetworkEvent {
Expand Down Expand Up @@ -72,6 +74,7 @@ impl Behaviour {
.redundancy_interval(Duration::from_millis(
config.benchmark.redundancy_interval_in_ms,
))
.max_transmit_size(MAX_TRANSMIT_SIZE)
.build()
.expect("Failed to build dog config"),
registry,
Expand All @@ -86,7 +89,10 @@ impl Behaviour {
Toggle::from({
let mut behaviour = gossipsub::Behaviour::new_with_metrics(
gossipsub::MessageAuthenticity::Signed(key.clone()),
gossipsub::Config::default(),
gossipsub::ConfigBuilder::default()
.max_transmit_size(MAX_TRANSMIT_SIZE)
.build()
.expect("Failed to build gossipsub config"),
registry,
Default::default(),
)
Expand Down
32 changes: 29 additions & 3 deletions benchmark/playbooks/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,36 @@
hosts: "{{ groups['machines'][0] }}"

tasks:
- name: Copy source code to remote machine
- name: Create directories
shell: |
mkdir -p /home/{{ ansible_ssh_user }}/libp2p-dog
mkdir -p /home/{{ ansible_ssh_user }}/libp2p-dog/benchmark
- name: Copy Cargo.toml to remote machine
synchronize:
src: "{{ playbook_dir }}/../../../libp2p-dog/Cargo.toml"
dest: /home/{{ ansible_ssh_user }}/libp2p-dog/Cargo.toml
mode: push
delete: true

- name: Copy dog directory to remote machine
synchronize:
src: "{{ playbook_dir }}/../../../libp2p-dog/dog"
dest: /home/{{ ansible_ssh_user }}/libp2p-dog/dog
mode: push
delete: true

- name: Copy benchmark code directory to remote machine
synchronize:
src: "{{ playbook_dir }}/../../../libp2p-dog/benchmark/code"
dest: /home/{{ ansible_ssh_user }}/libp2p-dog/benchmark/code
mode: push
delete: true

- name: Copy Dockerfile to remote machine
synchronize:
src: "{{ playbook_dir }}/../../../libp2p-dog"
dest: /home/{{ ansible_ssh_user }}
src: "{{ playbook_dir }}/../../../libp2p-dog/benchmark/Dockerfile"
dest: /home/{{ ansible_ssh_user }}/libp2p-dog/benchmark/Dockerfile
mode: push
delete: true

Expand Down
2 changes: 1 addition & 1 deletion dog/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ where
HandlerEvent::TransactionDropped(rpc) => {
tracing::warn!(
peer=%propagation_source,
"Dropped transaction from peer. Transaction: {:?}",
"Dropped transaction from peer. Transaction: {}",
rpc
);

Expand Down
17 changes: 17 additions & 0 deletions dog/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,23 @@ impl From<RpcOut> for proto::RPC {
}
}

impl std::fmt::Display for RpcOut {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
RpcOut::Publish { tx, .. } => {
write!(f, "Publish {{ from: {}, seqno: {} }}", tx.from, tx.seqno)
}
RpcOut::Forward { tx, .. } => {
write!(f, "Forward {{ from: {}, seqno: {} }}", tx.from, tx.seqno)
}
RpcOut::HaveTx(have_tx) => write!(f, "HaveTx {{ have_tx: {:?} }}", have_tx),
RpcOut::ResetRoute(reset_route) => {
write!(f, "ResetRoute {{ reset_route: {:?} }}", reset_route)
}
}
}
}

/// An RPC received/sent.
#[derive(Debug)]
pub struct Rpc {
Expand Down

0 comments on commit 2939d98

Please sign in to comment.