Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ordian committed Feb 11, 2020
1 parent 08f9853 commit 3aaedaf
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 133 deletions.
88 changes: 0 additions & 88 deletions parity/db/rocksdb/blooms.rs

This file was deleted.

40 changes: 1 addition & 39 deletions parity/db/rocksdb/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,47 +14,9 @@
// 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 std::collections::HashMap;
use std::path::Path;
use ethcore::client::ClientConfig;

/// Spreads the `total` (in MiB) memory budget across the db columns.
/// If it's `None`, the default memory budget will be used for each column.
/// 90% of the memory budget is assigned to the first column, `col0`, which is where we store the
/// state.
pub fn memory_per_column(total: Option<usize>) -> HashMap<u32, usize> {
let mut memory_per_column = HashMap::new();
if let Some(budget) = total {
// spend 90% of the memory budget on the state column, but at least 256 MiB
memory_per_column.insert(ethcore_db::COL_STATE, std::cmp::max(budget * 9 / 10, 256));
// spread the remaining 10% evenly across columns
let rest_budget = budget / 10 / (ethcore_db::NUM_COLUMNS as usize - 1);

for i in 1..ethcore_db::NUM_COLUMNS {
// but at least 16 MiB for each column
memory_per_column.insert(i, std::cmp::max(rest_budget, 16));
}
}
memory_per_column
}

/// Spreads the `total` (in MiB) memory budget across the light db columns.
pub fn memory_per_column_light(total: usize) -> HashMap<u32, usize> {
let mut memory_per_column = HashMap::new();
// spread the memory budget evenly across columns
// light client doesn't use the state column
let per_column = total / (ethcore_db::NUM_COLUMNS as usize - 1);

// Note: `col0` (State) is not used for the light client so setting it to a low value.
memory_per_column.insert(0, 1);
for i in 1..ethcore_db::NUM_COLUMNS {
// but at least 4 MiB for each column
memory_per_column.insert(i, std::cmp::max(per_column, 4));
}
memory_per_column
}

pub fn client_db_config(client_path: &Path, client_config: &ClientConfig) -> super::sled::DatabaseConfig {
pub fn client_db_config(client_config: &ClientConfig) -> super::sled::DatabaseConfig {
let mut client_db_config = super::sled::DatabaseConfig::with_columns(ethcore_db::NUM_COLUMNS);
client_db_config.memory_budget_mb = client_config.db_cache_size.map(|s| s as u64);
client_db_config
Expand Down
7 changes: 2 additions & 5 deletions parity/db/rocksdb/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ use self::kvdb_sled as sled;

use cache::CacheConfig;

mod blooms;
mod helpers;

struct AppDB {
Expand All @@ -56,8 +55,8 @@ impl BlockChainDB for AppDB {
}

/// Create a restoration db handler using the config generated by `client_path` and `client_config`.
pub fn restoration_db_handler(client_path: &Path, client_config: &ClientConfig) -> Box<dyn BlockChainDBHandler> {
let client_db_config = helpers::client_db_config(client_path, client_config);
pub fn restoration_db_handler(_client_path: &Path, client_config: &ClientConfig) -> Box<dyn BlockChainDBHandler> {
let client_db_config = helpers::client_db_config(client_config);

struct RestorationDBHandler {
config: sled::DatabaseConfig,
Expand All @@ -79,8 +78,6 @@ pub fn open_db_light(
client_path: &str,
cache_config: &CacheConfig,
) -> io::Result<Arc<dyn BlockChainDB>> {
let path = Path::new(client_path);

let db_config = sled::DatabaseConfig {
memory_budget_mb: Some(cache_config.blockchain() as u64),
.. sled::DatabaseConfig::with_columns(NUM_COLUMNS)
Expand Down
1 change: 0 additions & 1 deletion parity/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ pub fn execute_upgrades(
_ => {},
}

let client_path = dirs.db_path(pruning);
Ok(())
}

Expand Down

0 comments on commit 3aaedaf

Please sign in to comment.