using hashbrown + bumpalo in practice

This commit is contained in:
Folkert 2021-04-18 15:35:43 +02:00
parent 383f35db5a
commit cdf5b89f9a
5 changed files with 39 additions and 8 deletions

29
Cargo.lock generated
View file

@ -37,6 +37,17 @@ version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "739f4a8db6605981345c5654f3a85b056ce52f37a39d34da03f25bf2151ea16e"
[[package]]
name = "ahash"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f200cbb1e856866d9eade941cf3aa0c5d7dd36f74311c4273b494f4ef036957"
dependencies = [
"getrandom 0.2.2",
"once_cell",
"version_check",
]
[[package]]
name = "aho-corasick"
version = "0.7.15"
@ -1376,7 +1387,7 @@ checksum = "e8a70f1e87a3840ed6a3e99e02c2b861e4dbdf26f0d07e38f42ea5aff46cfce2"
dependencies = [
"bitflags",
"gpu-descriptor-types",
"hashbrown",
"hashbrown 0.9.1",
"tracing",
]
@ -1401,7 +1412,17 @@ version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04"
dependencies = [
"ahash",
"ahash 0.4.7",
]
[[package]]
name = "hashbrown"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
dependencies = [
"ahash 0.7.2",
"bumpalo",
]
[[package]]
@ -1497,7 +1518,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3"
dependencies = [
"autocfg 1.0.1",
"hashbrown",
"hashbrown 0.9.1",
]
[[package]]
@ -2950,6 +2971,7 @@ name = "roc_collections"
version = "0.1.0"
dependencies = [
"bumpalo",
"hashbrown 0.11.2",
"im 14.3.0",
"im-rc 14.3.0",
"wyhash",
@ -3181,6 +3203,7 @@ name = "roc_mono"
version = "0.1.0"
dependencies = [
"bumpalo",
"hashbrown 0.11.2",
"indoc 0.3.6",
"linked-hash-map",
"maplit",

View file

@ -10,3 +10,4 @@ im = "14" # im and im-rc should always have the same version!
im-rc = "14" # im and im-rc should always have the same version!
wyhash = "0.3"
bumpalo = { version = "3.6.1", features = ["collections"] }
hashbrown = { version = "0.11.2", features = [ "bumpalo" ] }

View file

@ -28,6 +28,8 @@ pub type SendMap<K, V> = im::hashmap::HashMap<K, V, BuildHasher>;
pub type SendSet<K> = im::hashset::HashSet<K, BuildHasher>;
pub type BumpMap<'a, K, V> = hashbrown::HashMap<K, V, BuildHasher, hashbrown::BumpWrapper<'a>>;
pub fn arena_join<'a, I>(arena: &'a Bump, strings: &mut I, join_str: &str) -> String<'a>
where
I: Iterator<Item = &'a str>,

View file

@ -16,6 +16,7 @@ roc_solve = { path = "../solve" }
roc_problem = { path = "../problem" }
ven_pretty = { path = "../../vendor/pretty" }
bumpalo = { version = "3.6.1", features = ["collections"] }
hashbrown = { version = "0.11.2", features = [ "bumpalo" ] }
ven_ena = { path = "../../vendor/ena" }
linked-hash-map = "0.5.4"

View file

@ -6,7 +6,7 @@ use crate::layout::{
};
use bumpalo::collections::Vec;
use bumpalo::Bump;
use roc_collections::all::{default_hasher, MutMap, MutSet};
use roc_collections::all::{default_hasher, BumpMap, MutMap, MutSet};
use roc_module::ident::{ForeignSymbol, Lowercase, TagName};
use roc_module::low_level::LowLevel;
use roc_module::symbol::{IdentIds, ModuleId, Symbol};
@ -126,8 +126,8 @@ pub struct Proc<'a> {
pub enum HostExposedLayouts<'a> {
NotHostExposed,
HostExposed {
rigids: MutMap<Lowercase, Layout<'a>>,
aliases: MutMap<Symbol, Layout<'a>>,
rigids: BumpMap<'a, Lowercase, Layout<'a>>,
aliases: BumpMap<'a, Symbol, Layout<'a>>,
},
}
@ -1833,7 +1833,8 @@ fn specialize_external<'a>(
let host_exposed_layouts = if host_exposed_variables.is_empty() {
HostExposedLayouts::NotHostExposed
} else {
let mut aliases = MutMap::default();
let mut aliases =
hashbrown::HashMap::with_hasher_in(default_hasher(), hashbrown::BumpWrapper(env.arena));
for (symbol, variable) in host_exposed_variables {
let layout = layout_cache
@ -1843,7 +1844,10 @@ fn specialize_external<'a>(
}
HostExposedLayouts::HostExposed {
rigids: MutMap::default(),
rigids: hashbrown::HashMap::with_hasher_in(
default_hasher(),
hashbrown::BumpWrapper(env.arena),
),
aliases,
}
};