Prometheus, heavy memory calls removed (#27)

This commit is contained in:
rakita
2020-09-14 16:08:57 +02:00
committed by GitHub
parent dd38573a28
commit aecc6fc862
55 changed files with 3953 additions and 179 deletions

View File

@@ -575,7 +575,7 @@ where
let status = self.sync.status();
let client = &self.client;
let snapshot_status = self.snapshot.status();
let snapshot_status = self.snapshot.restoration_status();
let (warping, warp_chunks_amount, warp_chunks_processed) = match snapshot_status {
RestorationStatus::Ongoing {
@@ -583,6 +583,7 @@ where
block_chunks,
state_chunks_done,
block_chunks_done,
..
} => (
true,
Some(block_chunks + state_chunks),

View File

@@ -29,6 +29,7 @@ use ethereum_types::{Address, H160, H256, H512, H64, U256, U64};
use ethkey::{crypto::ecies, Brain, Generator};
use ethstore::random_phrase;
use jsonrpc_core::{futures::future, BoxFuture, Result};
use stats::PrometheusMetrics;
use sync::{ManageNetwork, SyncProvider};
use types::ids::BlockId;
use version::version_data;
@@ -52,7 +53,10 @@ use v1::{
use Host;
/// Parity implementation.
pub struct ParityClient<C, M> {
pub struct ParityClient<C, M>
where
C: PrometheusMetrics,
{
client: Arc<C>,
miner: Arc<M>,
sync: Arc<dyn SyncProvider>,
@@ -66,7 +70,7 @@ pub struct ParityClient<C, M> {
impl<C, M> ParityClient<C, M>
where
C: BlockChainClient,
C: BlockChainClient + PrometheusMetrics,
{
/// Creates new `ParityClient`.
pub fn new(
@@ -99,6 +103,7 @@ where
S: StateInfo + 'static,
C: miner::BlockChainClient
+ BlockChainClient
+ PrometheusMetrics
+ StateClient<State = S>
+ Call<State = S>
+ 'static,
@@ -458,7 +463,7 @@ where
fn status(&self) -> Result<()> {
let has_peers = self.settings.is_dev_chain || self.sync.status().num_peers > 0;
let is_warping = match self.snapshot.as_ref().map(|s| s.status()) {
let is_warping = match self.snapshot.as_ref().map(|s| s.restoration_status()) {
Some(RestorationStatus::Ongoing { .. }) => true,
_ => false,
};

View File

@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
use ethcore::snapshot::{ManifestData, RestorationStatus, SnapshotService};
use ethcore::snapshot::{CreationStatus, ManifestData, RestorationStatus, SnapshotService};
use bytes::Bytes;
use ethereum_types::H256;
@@ -53,9 +53,12 @@ impl SnapshotService for TestSnapshotService {
fn chunk(&self, _hash: H256) -> Option<Bytes> {
None
}
fn status(&self) -> RestorationStatus {
fn restoration_status(&self) -> RestorationStatus {
self.status.lock().clone()
}
fn creation_status(&self) -> CreationStatus {
CreationStatus::Inactive
}
fn begin_restore(&self, _manifest: ManifestData) {}
fn abort_restore(&self) {}
fn abort_snapshot(&self) {}

View File

@@ -19,6 +19,7 @@
use ethereum_types::H256;
use network::client_version::ClientVersion;
use parking_lot::RwLock;
use stats::{prometheus, PrometheusMetrics};
use std::collections::BTreeMap;
use sync::{EthProtocolInfo, PeerInfo, SyncProvider, SyncState, SyncStatus, TransactionStats};
@@ -51,10 +52,10 @@ impl TestSyncProvider {
blocks_received: 0,
num_peers: config.num_peers,
num_active_peers: 0,
mem_used: 0,
num_snapshot_chunks: 0,
snapshot_chunks_done: 0,
last_imported_old_block_number: None,
item_sizes: BTreeMap::new(),
}),
}
}
@@ -67,6 +68,10 @@ impl TestSyncProvider {
}
}
impl PrometheusMetrics for TestSyncProvider {
fn prometheus_metrics(&self, _: &mut prometheus::Registry) {}
}
impl SyncProvider for TestSyncProvider {
fn status(&self) -> SyncStatus {
self.status.read().clone()

View File

@@ -180,6 +180,7 @@ fn rpc_eth_syncing() {
let snap_res = r#"{"jsonrpc":"2.0","result":{"currentBlock":"0x3e8","highestBlock":"0x9c4","startingBlock":"0x0","warpChunksAmount":"0x32","warpChunksProcessed":"0x18"},"id":1}"#;
tester.snapshot.set_status(RestorationStatus::Ongoing {
block_number: 0,
state_chunks: 40,
block_chunks: 10,
state_chunks_done: 18,