mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 23:31:12 +00:00
using hashbrown + bumpalo in practice
This commit is contained in:
parent
383f35db5a
commit
cdf5b89f9a
5 changed files with 39 additions and 8 deletions
29
Cargo.lock
generated
29
Cargo.lock
generated
|
@ -37,6 +37,17 @@ version = "0.4.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "739f4a8db6605981345c5654f3a85b056ce52f37a39d34da03f25bf2151ea16e"
|
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]]
|
[[package]]
|
||||||
name = "aho-corasick"
|
name = "aho-corasick"
|
||||||
version = "0.7.15"
|
version = "0.7.15"
|
||||||
|
@ -1376,7 +1387,7 @@ checksum = "e8a70f1e87a3840ed6a3e99e02c2b861e4dbdf26f0d07e38f42ea5aff46cfce2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"gpu-descriptor-types",
|
"gpu-descriptor-types",
|
||||||
"hashbrown",
|
"hashbrown 0.9.1",
|
||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1401,7 +1412,17 @@ version = "0.9.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04"
|
checksum = "d7afe4a420e3fe79967a00898cc1f4db7c8a49a9333a29f8a4bd76a253d5cd04"
|
||||||
dependencies = [
|
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]]
|
[[package]]
|
||||||
|
@ -1497,7 +1518,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3"
|
checksum = "824845a0bf897a9042383849b02c1bc219c2383772efcd5c6f9766fa4b81aef3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"autocfg 1.0.1",
|
"autocfg 1.0.1",
|
||||||
"hashbrown",
|
"hashbrown 0.9.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -2950,6 +2971,7 @@ name = "roc_collections"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bumpalo",
|
"bumpalo",
|
||||||
|
"hashbrown 0.11.2",
|
||||||
"im 14.3.0",
|
"im 14.3.0",
|
||||||
"im-rc 14.3.0",
|
"im-rc 14.3.0",
|
||||||
"wyhash",
|
"wyhash",
|
||||||
|
@ -3181,6 +3203,7 @@ name = "roc_mono"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bumpalo",
|
"bumpalo",
|
||||||
|
"hashbrown 0.11.2",
|
||||||
"indoc 0.3.6",
|
"indoc 0.3.6",
|
||||||
"linked-hash-map",
|
"linked-hash-map",
|
||||||
"maplit",
|
"maplit",
|
||||||
|
|
|
@ -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!
|
im-rc = "14" # im and im-rc should always have the same version!
|
||||||
wyhash = "0.3"
|
wyhash = "0.3"
|
||||||
bumpalo = { version = "3.6.1", features = ["collections"] }
|
bumpalo = { version = "3.6.1", features = ["collections"] }
|
||||||
|
hashbrown = { version = "0.11.2", features = [ "bumpalo" ] }
|
||||||
|
|
|
@ -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 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>
|
pub fn arena_join<'a, I>(arena: &'a Bump, strings: &mut I, join_str: &str) -> String<'a>
|
||||||
where
|
where
|
||||||
I: Iterator<Item = &'a str>,
|
I: Iterator<Item = &'a str>,
|
||||||
|
|
|
@ -16,6 +16,7 @@ roc_solve = { path = "../solve" }
|
||||||
roc_problem = { path = "../problem" }
|
roc_problem = { path = "../problem" }
|
||||||
ven_pretty = { path = "../../vendor/pretty" }
|
ven_pretty = { path = "../../vendor/pretty" }
|
||||||
bumpalo = { version = "3.6.1", features = ["collections"] }
|
bumpalo = { version = "3.6.1", features = ["collections"] }
|
||||||
|
hashbrown = { version = "0.11.2", features = [ "bumpalo" ] }
|
||||||
ven_ena = { path = "../../vendor/ena" }
|
ven_ena = { path = "../../vendor/ena" }
|
||||||
linked-hash-map = "0.5.4"
|
linked-hash-map = "0.5.4"
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ use crate::layout::{
|
||||||
};
|
};
|
||||||
use bumpalo::collections::Vec;
|
use bumpalo::collections::Vec;
|
||||||
use bumpalo::Bump;
|
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::ident::{ForeignSymbol, Lowercase, TagName};
|
||||||
use roc_module::low_level::LowLevel;
|
use roc_module::low_level::LowLevel;
|
||||||
use roc_module::symbol::{IdentIds, ModuleId, Symbol};
|
use roc_module::symbol::{IdentIds, ModuleId, Symbol};
|
||||||
|
@ -126,8 +126,8 @@ pub struct Proc<'a> {
|
||||||
pub enum HostExposedLayouts<'a> {
|
pub enum HostExposedLayouts<'a> {
|
||||||
NotHostExposed,
|
NotHostExposed,
|
||||||
HostExposed {
|
HostExposed {
|
||||||
rigids: MutMap<Lowercase, Layout<'a>>,
|
rigids: BumpMap<'a, Lowercase, Layout<'a>>,
|
||||||
aliases: MutMap<Symbol, 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() {
|
let host_exposed_layouts = if host_exposed_variables.is_empty() {
|
||||||
HostExposedLayouts::NotHostExposed
|
HostExposedLayouts::NotHostExposed
|
||||||
} else {
|
} 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 {
|
for (symbol, variable) in host_exposed_variables {
|
||||||
let layout = layout_cache
|
let layout = layout_cache
|
||||||
|
@ -1843,7 +1844,10 @@ fn specialize_external<'a>(
|
||||||
}
|
}
|
||||||
|
|
||||||
HostExposedLayouts::HostExposed {
|
HostExposedLayouts::HostExposed {
|
||||||
rigids: MutMap::default(),
|
rigids: hashbrown::HashMap::with_hasher_in(
|
||||||
|
default_hasher(),
|
||||||
|
hashbrown::BumpWrapper(env.arena),
|
||||||
|
),
|
||||||
aliases,
|
aliases,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue