mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
decrease default tracing permits (#7010)
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
@ -148,8 +148,8 @@ pub struct RpcServerArgs {
|
||||
pub rpc_max_connections: MaxU32,
|
||||
|
||||
/// Maximum number of concurrent tracing requests.
|
||||
#[arg(long, value_name = "COUNT", default_value_t = constants::DEFAULT_MAX_TRACING_REQUESTS)]
|
||||
pub rpc_max_tracing_requests: u32,
|
||||
#[arg(long, value_name = "COUNT", default_value_t = constants::default_max_tracing_requests())]
|
||||
pub rpc_max_tracing_requests: usize,
|
||||
|
||||
/// Maximum number of blocks that could be scanned per filter request. (0 = entire chain)
|
||||
#[arg(long, value_name = "COUNT", default_value_t = ZeroAsNoneU64::new(constants::DEFAULT_MAX_BLOCKS_PER_FILTER))]
|
||||
@ -499,7 +499,7 @@ impl Default for RpcServerArgs {
|
||||
rpc_max_response_size: RPC_DEFAULT_MAX_RESPONSE_SIZE_MB.into(),
|
||||
rpc_max_subscriptions_per_connection: RPC_DEFAULT_MAX_SUBS_PER_CONN.into(),
|
||||
rpc_max_connections: RPC_DEFAULT_MAX_CONNECTIONS.into(),
|
||||
rpc_max_tracing_requests: constants::DEFAULT_MAX_TRACING_REQUESTS,
|
||||
rpc_max_tracing_requests: constants::default_max_tracing_requests(),
|
||||
rpc_max_blocks_per_filter: constants::DEFAULT_MAX_BLOCKS_PER_FILTER.into(),
|
||||
rpc_max_logs_per_response: (constants::DEFAULT_MAX_LOGS_PER_RESPONSE as u64).into(),
|
||||
rpc_gas_cap: RPC_DEFAULT_GAS_CAP.into(),
|
||||
|
||||
@ -3,6 +3,7 @@ pub use reth_rpc::eth::gas_oracle::{
|
||||
DEFAULT_GAS_PRICE_BLOCKS, DEFAULT_GAS_PRICE_PERCENTILE, DEFAULT_IGNORE_GAS_PRICE,
|
||||
DEFAULT_MAX_GAS_PRICE,
|
||||
};
|
||||
use std::cmp::max;
|
||||
|
||||
/// The default port for the http server
|
||||
pub const DEFAULT_HTTP_RPC_PORT: u16 = 8545;
|
||||
@ -19,8 +20,16 @@ pub const DEFAULT_MAX_BLOCKS_PER_FILTER: u64 = 100_000;
|
||||
/// The default maximum of logs in a single response.
|
||||
pub const DEFAULT_MAX_LOGS_PER_RESPONSE: usize = 20_000;
|
||||
|
||||
/// The default maximum number of concurrently executed tracing calls
|
||||
pub const DEFAULT_MAX_TRACING_REQUESTS: u32 = 25;
|
||||
/// The default maximum number tracing requests we're allowing concurrently.
|
||||
/// Tracing is mostly CPU bound so we're limiting the number of concurrent requests to something
|
||||
/// lower that the number of cores, in order to minimize the impact on the rest of the system.
|
||||
pub fn default_max_tracing_requests() -> usize {
|
||||
// We reserve 2 cores for the rest of the system
|
||||
const RESERVED: usize = 2;
|
||||
|
||||
std::thread::available_parallelism()
|
||||
.map_or(25, |cpus| max(cpus.get().saturating_sub(RESERVED), RESERVED))
|
||||
}
|
||||
|
||||
/// The default IPC endpoint
|
||||
#[cfg(windows)]
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
use crate::constants::{
|
||||
DEFAULT_MAX_BLOCKS_PER_FILTER, DEFAULT_MAX_LOGS_PER_RESPONSE, DEFAULT_MAX_TRACING_REQUESTS,
|
||||
default_max_tracing_requests, DEFAULT_MAX_BLOCKS_PER_FILTER, DEFAULT_MAX_LOGS_PER_RESPONSE,
|
||||
};
|
||||
use reth_rpc::{
|
||||
eth::{
|
||||
@ -35,7 +35,7 @@ pub struct EthConfig {
|
||||
/// Settings for the gas price oracle
|
||||
pub gas_oracle: GasPriceOracleConfig,
|
||||
/// The maximum number of tracing calls that can be executed in concurrently.
|
||||
pub max_tracing_requests: u32,
|
||||
pub max_tracing_requests: usize,
|
||||
/// Maximum number of blocks that could be scanned per filter request in `eth_getLogs` calls.
|
||||
pub max_blocks_per_filter: u64,
|
||||
/// Maximum number of logs that can be returned in a single response in `eth_getLogs` calls.
|
||||
@ -69,7 +69,7 @@ impl Default for EthConfig {
|
||||
Self {
|
||||
cache: EthStateCacheConfig::default(),
|
||||
gas_oracle: GasPriceOracleConfig::default(),
|
||||
max_tracing_requests: DEFAULT_MAX_TRACING_REQUESTS,
|
||||
max_tracing_requests: default_max_tracing_requests(),
|
||||
max_blocks_per_filter: DEFAULT_MAX_BLOCKS_PER_FILTER,
|
||||
max_logs_per_response: DEFAULT_MAX_LOGS_PER_RESPONSE,
|
||||
rpc_gas_cap: RPC_DEFAULT_GAS_CAP.into(),
|
||||
@ -93,7 +93,7 @@ impl EthConfig {
|
||||
}
|
||||
|
||||
/// Configures the maximum number of tracing requests
|
||||
pub fn max_tracing_requests(mut self, max_requests: u32) -> Self {
|
||||
pub fn max_tracing_requests(mut self, max_requests: usize) -> Self {
|
||||
self.max_tracing_requests = max_requests;
|
||||
self
|
||||
}
|
||||
|
||||
@ -24,8 +24,8 @@ pub struct BlockingTaskGuard(Arc<Semaphore>);
|
||||
impl BlockingTaskGuard {
|
||||
/// Create a new `BlockingTaskGuard` with the given maximum number of blocking tasks in
|
||||
/// parallel.
|
||||
pub fn new(max_blocking_tasks: u32) -> Self {
|
||||
Self(Arc::new(Semaphore::new(max_blocking_tasks as usize)))
|
||||
pub fn new(max_blocking_tasks: usize) -> Self {
|
||||
Self(Arc::new(Semaphore::new(max_blocking_tasks)))
|
||||
}
|
||||
|
||||
/// See also [Semaphore::acquire_owned]
|
||||
|
||||
Reference in New Issue
Block a user