Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions utils/frame/remote-externalities/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use sp_core::{
pub use sp_io::TestExternalities;
use sp_runtime::{traits::Block as BlockT, StateVersion};
use std::{
cmp::max,
cmp::{max, min},
fs,
num::NonZeroUsize,
ops::{Deref, DerefMut},
Expand Down Expand Up @@ -157,10 +157,14 @@ impl Transport {
} else {
uri.clone()
};
let http_client = HttpClientBuilder::default().build(uri).map_err(|e| {
log::error!(target: LOG_TARGET, "error: {:?}", e);
"failed to build http client"
})?;
let http_client = HttpClientBuilder::default()
.max_request_body_size(u32::MAX)
.request_timeout(std::time::Duration::from_secs(60 * 5))
.build(uri)
.map_err(|e| {
log::error!(target: LOG_TARGET, "error: {:?}", e);
"failed to build http client"
})?;

*self = Self::RemoteClient(Arc::new(http_client))
}
Expand Down Expand Up @@ -323,16 +327,23 @@ where
B::Hash: DeserializeOwned,
B::Header: DeserializeOwned,
{
const MAX_PARALLELISM: usize = 4;
const BATCH_SIZE_INCREASE_FACTOR: f32 = 1.10;
const BATCH_SIZE_DECREASE_FACTOR: f32 = 0.50;
const INITIAL_BATCH_SIZE: usize = 5000;
// NOTE: increasing this value does not seem to impact speed all that much.
const DEFAULT_KEY_DOWNLOAD_PAGE: u32 = 1000;

/// Get the number of threads to use.
/// Cap the number of threads. Performance improvement beyond a small number of threads is
/// negligible, and too many threads can create issues with the HttpClient.
fn threads() -> NonZeroUsize {
thread::available_parallelism()
.unwrap_or(NonZeroUsize::new(1usize).expect("4 is non-zero; qed"))
let avaliable = thread::available_parallelism()
.unwrap_or(NonZeroUsize::new(1usize).expect("1 is non-zero; qed"))
.get();
assert!(avaliable > 0, "avaliable parallelism must be greater than 0");
return NonZeroUsize::new(min(avaliable, Self::MAX_PARALLELISM))
.expect("avaliable is non-zero and MAX_PARRELISM is non-zero; qed")
}

async fn rpc_get_storage(
Expand Down