-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #154 from input-output-hk/imhamt-box-optimisation
Optimise HAMT inner representation to use Box instead of Vec
- Loading branch information
Showing
10 changed files
with
421 additions
and
500 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#[cfg(unix)] | ||
mod unix; | ||
|
||
#[cfg(unix)] | ||
use unix::run; | ||
|
||
#[cfg(not(unix))] | ||
fn run() { | ||
println!("example not supported on this platform") | ||
} | ||
|
||
fn main() { | ||
run() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
extern crate imhamt; | ||
extern crate jemalloc_ctl; | ||
extern crate jemallocator; | ||
|
||
use jemalloc_ctl::{epoch, stats}; | ||
use std::collections::hash_map::DefaultHasher; | ||
use std::thread; | ||
use std::time::Duration; | ||
|
||
#[global_allocator] | ||
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; | ||
|
||
use imhamt::Hamt; | ||
|
||
fn statprint() { | ||
let allocated = stats::allocated::read().unwrap(); | ||
let resident = stats::resident::read().unwrap(); | ||
println!("{} bytes allocated/{} bytes resident", allocated, resident); | ||
} | ||
|
||
pub fn run() { | ||
let mut h: Hamt<DefaultHasher, u32, u32> = Hamt::new(); | ||
|
||
println!("adding 100000 entries"); | ||
|
||
for i in 0..100000 { | ||
h = h.insert(i, i).unwrap(); | ||
} | ||
|
||
let mut h2 = h.clone(); | ||
|
||
epoch::advance().unwrap(); | ||
|
||
statprint(); | ||
thread::sleep(Duration::from_secs(10)); | ||
|
||
println!("adding 100000 entries"); | ||
|
||
for i in 100000..200000 { | ||
h2 = h2.insert(i, i).unwrap(); | ||
} | ||
|
||
epoch::advance().unwrap(); | ||
|
||
statprint(); | ||
thread::sleep(Duration::from_secs(10)); | ||
|
||
epoch::advance().unwrap(); | ||
|
||
statprint(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.