From 32edee9bbbb5c4750c7787560944a47de03b61f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Frosteg=C3=A5rd?= Date: Thu, 9 Apr 2020 10:14:53 +0200 Subject: [PATCH] aquatic: add #[inline] to handle_readable_socket and handlers Also update aquatic_bench comment with new bench results --- aquatic/src/lib/handlers.rs | 4 ++++ aquatic/src/lib/network.rs | 1 + aquatic_bench/src/bin/bench_handlers/main.rs | 10 +++++----- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/aquatic/src/lib/handlers.rs b/aquatic/src/lib/handlers.rs index 543512d..443c8e0 100644 --- a/aquatic/src/lib/handlers.rs +++ b/aquatic/src/lib/handlers.rs @@ -11,6 +11,7 @@ use crate::common::*; use crate::config::Config; +#[inline] pub fn handle_connect_requests( state: &State, rng: &mut StdRng, @@ -41,6 +42,7 @@ pub fn handle_connect_requests( } +#[inline] pub fn handle_announce_requests( state: &State, config: &Config, @@ -128,6 +130,7 @@ pub fn handle_announce_requests( } +#[inline] pub fn handle_scrape_requests( state: &State, responses: &mut Vec<(Response, SocketAddr)>, @@ -177,6 +180,7 @@ pub fn handle_scrape_requests( /// in order to avoid returning too homogeneous peers. /// /// Don't care if we send back announcing peer. +#[inline] pub fn extract_response_peers( rng: &mut impl Rng, peer_map: &PeerMap, diff --git a/aquatic/src/lib/network.rs b/aquatic/src/lib/network.rs index ca90893..468372f 100644 --- a/aquatic/src/lib/network.rs +++ b/aquatic/src/lib/network.rs @@ -109,6 +109,7 @@ fn create_socket(config: &Config) -> ::std::net::UdpSocket { /// Read requests, generate and send back responses +#[inline] fn handle_readable_socket( state: &State, config: &Config, diff --git a/aquatic_bench/src/bin/bench_handlers/main.rs b/aquatic_bench/src/bin/bench_handlers/main.rs index 6e8ae84..dcfe4f8 100644 --- a/aquatic_bench/src/bin/bench_handlers/main.rs +++ b/aquatic_bench/src/bin/bench_handlers/main.rs @@ -2,11 +2,11 @@ //! //! Example summary output: //! ``` -//! ## Average results over 10 rounds -//! -//! Connect handler: 2 280 522 requests/second, 439.29 ns/request -//! Announce handler: 267 790 requests/second, 3736.05 ns/request -//! Scrape handler: 570 958 requests/second, 1751.89 ns/request +//! ## Average results over 50 rounds +//! +//! Connect handler: 2 613 265 requests/second, 383.21 ns/request +//! Announce handler: 293 403 requests/second, 3427.20 ns/request +//! Scrape handler: 670 001 requests/second, 1492.61 ns/request //! ``` use std::time::{Duration, Instant};