Skip to content

Commit

Permalink
Switch to using hashbrown version of HashMap and (#2158)
Browse files Browse the repository at this point in the history
HashSet for improved performance and memory usage
  • Loading branch information
sambley authored Dec 14, 2018
1 parent 8fcb711 commit 8ee0e96
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 8 deletions.
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ solana-vote-signer = { path = "vote-signer", version = "0.0.1" }
tokio = "0.1"
tokio-codec = "0.1"
untrusted = "0.6.2"
hashbrown = "0.1.7"

[[bench]]
name = "bank"
Expand Down
5 changes: 3 additions & 2 deletions src/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use crate::runtime::{self, RuntimeError};
use crate::storage_stage::StorageState;
use bincode::deserialize;
use bincode::serialize;
use hashbrown::{HashMap, HashSet};
use itertools::Itertools;
use log::Level;
use rayon::prelude::*;
Expand All @@ -38,7 +39,7 @@ use solana_sdk::token_program;
use solana_sdk::transaction::Transaction;
use solana_sdk::vote_program;
use std;
use std::collections::{BTreeMap, HashMap, HashSet, VecDeque};
use std::collections::{BTreeMap, VecDeque};
use std::result;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Arc, Mutex, RwLock};
Expand Down Expand Up @@ -207,7 +208,7 @@ pub struct Accounts {

impl Accounts {
/// Returns a read-only iterator over all known accounts
pub fn account_values(&self) -> std::collections::hash_map::Values<Pubkey, Account> {
pub fn account_values(&self) -> hashbrown::hash_map::Values<Pubkey, Account> {
self.accounts.values()
}

Expand Down
2 changes: 1 addition & 1 deletion src/cluster_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use crate::rpc::RPC_PORT;
use crate::streamer::{BlobReceiver, BlobSender};
use crate::window::{SharedWindow, WindowIndex};
use bincode::{deserialize, serialize};
use hashbrown::HashMap;
use log::Level;
use rand::{thread_rng, Rng};
use rayon::prelude::*;
Expand All @@ -35,7 +36,6 @@ use solana_sdk::hash::Hash;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::{Keypair, KeypairUtil, Signable, Signature};
use solana_sdk::timing::{duration_as_ms, timestamp};
use std::collections::HashMap;
use std::io;
use std::net::{IpAddr, Ipv4Addr, SocketAddr, UdpSocket};
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
Expand Down
2 changes: 1 addition & 1 deletion src/crds_gossip_pull.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ use crate::crds_gossip_error::CrdsGossipError;
use crate::crds_value::{CrdsValue, CrdsValueLabel};
use crate::packet::BLOB_DATA_SIZE;
use bincode::serialized_size;
use hashbrown::HashMap;
use rand;
use rand::distributions::{Distribution, WeightedIndex};
use solana_sdk::hash::Hash;
use solana_sdk::pubkey::Pubkey;
use std::cmp;
use std::collections::HashMap;
use std::collections::VecDeque;

pub const CRDS_GOSSIP_PULL_CRDS_TIMEOUT_MS: u64 = 15000;
Expand Down
2 changes: 1 addition & 1 deletion src/crds_gossip_push.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ use crate::crds_gossip_error::CrdsGossipError;
use crate::crds_value::{CrdsValue, CrdsValueLabel};
use crate::packet::BLOB_DATA_SIZE;
use bincode::serialized_size;
use hashbrown::HashMap;
use indexmap::map::IndexMap;
use rand;
use rand::seq::SliceRandom;
use solana_sdk::hash::Hash;
use solana_sdk::pubkey::Pubkey;
use std::cmp;
use std::collections::HashMap;

pub const CRDS_GOSSIP_NUM_ACTIVE: usize = 30;
pub const CRDS_GOSSIP_PUSH_FANOUT: usize = 6;
Expand Down
4 changes: 2 additions & 2 deletions src/leader_scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ use crate::entry::Entry;
use crate::ledger::create_ticks;
use bincode::serialize;
use byteorder::{LittleEndian, ReadBytesExt};
use hashbrown::HashSet;
use solana_sdk::hash::{hash, Hash};
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::system_transaction::SystemTransaction;
use solana_sdk::transaction::Transaction;
use solana_sdk::vote_program::{self, Vote, VoteProgram};
use solana_sdk::vote_transaction::VoteTransaction;
use std::collections::HashSet;
use std::io::Cursor;

pub const DEFAULT_BOOTSTRAP_HEIGHT: u64 = 1000;
Expand Down Expand Up @@ -519,13 +519,13 @@ mod tests {
DEFAULT_LEADER_ROTATION_INTERVAL, DEFAULT_SEED_ROTATION_INTERVAL,
};
use crate::mint::Mint;
use hashbrown::HashSet;
use solana_sdk::hash::Hash;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::{Keypair, KeypairUtil};
use solana_sdk::transaction::Transaction;
use solana_sdk::vote_program::Vote;
use solana_sdk::vote_transaction::VoteTransaction;
use std::collections::HashSet;
use std::hash::Hash as StdHash;
use std::iter::FromIterator;

Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ pub mod window_service;
#[cfg(any(feature = "chacha", feature = "cuda"))]
#[macro_use]
extern crate hex_literal;
extern crate hashbrown;

#[macro_use]
extern crate log;
Expand Down
2 changes: 1 addition & 1 deletion src/thin_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::result::{Error, Result};
use crate::rpc_request::{RpcClient, RpcRequest};
use bincode::serialize;
use bs58;
use hashbrown::HashMap;
use log::Level;
use serde_json;
use solana_metrics;
Expand All @@ -23,7 +24,6 @@ use solana_sdk::system_transaction::SystemTransaction;
use solana_sdk::timing;
use solana_sdk::transaction::Transaction;
use std;
use std::collections::HashMap;
use std::io;
use std::net::{SocketAddr, UdpSocket};
use std::sync::atomic::AtomicBool;
Expand Down

0 comments on commit 8ee0e96

Please sign in to comment.