udp: PendingScrapeResponseSlab: use normal hashmap instead of amortized

This commit is contained in:
Joakim Frostegård 2022-04-14 17:23:50 +02:00
parent 256975a43c
commit 9479828b4a
3 changed files with 7 additions and 3 deletions

1
Cargo.lock generated
View file

@ -213,6 +213,7 @@ dependencies = [
"cfg-if", "cfg-if",
"crossbeam-channel", "crossbeam-channel",
"getrandom", "getrandom",
"hashbrown 0.12.0",
"hex", "hex",
"log", "log",
"mimalloc", "mimalloc",

View file

@ -28,6 +28,7 @@ blake3 = "1"
cfg-if = "1" cfg-if = "1"
crossbeam-channel = "0.5" crossbeam-channel = "0.5"
getrandom = "0.2" getrandom = "0.2"
hashbrown = { version = "0.12", default-features = false }
hex = "0.4" hex = "0.4"
log = "0.4" log = "0.4"
mimalloc = { version = "0.1", default-features = false } mimalloc = { version = "0.1", default-features = false }

View file

@ -7,13 +7,14 @@ use std::vec::Drain;
use anyhow::Context; use anyhow::Context;
use aquatic_common::privileges::PrivilegeDropper; use aquatic_common::privileges::PrivilegeDropper;
use crossbeam_channel::Receiver; use crossbeam_channel::Receiver;
use hashbrown::HashMap;
use mio::net::UdpSocket; use mio::net::UdpSocket;
use mio::{Events, Interest, Poll, Token}; use mio::{Events, Interest, Poll, Token};
use slab::Slab; use slab::Slab;
use aquatic_common::access_list::create_access_list_cache; use aquatic_common::access_list::create_access_list_cache;
use aquatic_common::access_list::AccessListCache; use aquatic_common::access_list::AccessListCache;
use aquatic_common::{AmortizedIndexMap, CanonicalSocketAddr}; use aquatic_common::CanonicalSocketAddr;
use aquatic_common::{PanicSentinel, ValidUntil}; use aquatic_common::{PanicSentinel, ValidUntil};
use aquatic_udp_protocol::*; use aquatic_udp_protocol::*;
use socket2::{Domain, Protocol, Socket, Type}; use socket2::{Domain, Protocol, Socket, Type};
@ -39,8 +40,9 @@ impl PendingScrapeResponseSlab {
request: ScrapeRequest, request: ScrapeRequest,
valid_until: ValidUntil, valid_until: ValidUntil,
) -> impl IntoIterator<Item = (RequestWorkerIndex, PendingScrapeRequest)> { ) -> impl IntoIterator<Item = (RequestWorkerIndex, PendingScrapeRequest)> {
let mut split_requests: AmortizedIndexMap<RequestWorkerIndex, PendingScrapeRequest> = let capacity = config.request_workers.min(request.info_hashes.len());
Default::default(); let mut split_requests: HashMap<RequestWorkerIndex, PendingScrapeRequest> =
HashMap::with_capacity(capacity);
if request.info_hashes.is_empty() { if request.info_hashes.is_empty() {
::log::warn!( ::log::warn!(