From 383f35db5a7a5fcc032bf452f2d685db34ef2e1b Mon Sep 17 00:00:00 2001 From: Folkert Date: Sun, 18 Apr 2021 14:36:47 +0200 Subject: [PATCH 1/2] bump bumpalo --- compiler/build/Cargo.toml | 2 +- compiler/can/Cargo.toml | 2 +- compiler/collections/Cargo.toml | 2 +- compiler/fmt/Cargo.toml | 2 +- compiler/gen/Cargo.toml | 4 ++-- compiler/gen_dev/Cargo.toml | 4 ++-- compiler/load/Cargo.toml | 2 +- compiler/module/Cargo.toml | 2 +- compiler/mono/Cargo.toml | 2 +- compiler/parse/Cargo.toml | 2 +- compiler/parse/fuzz/Cargo.toml | 2 +- compiler/reporting/Cargo.toml | 2 +- compiler/solve/Cargo.toml | 2 +- compiler/str/Cargo.toml | 2 +- compiler/test_gen/Cargo.toml | 4 ++-- editor/Cargo.toml | 2 +- 16 files changed, 19 insertions(+), 19 deletions(-) diff --git a/compiler/build/Cargo.toml b/compiler/build/Cargo.toml index 810ed7f759d..30cac8cf1c2 100644 --- a/compiler/build/Cargo.toml +++ b/compiler/build/Cargo.toml @@ -23,7 +23,7 @@ roc_gen = { path = "../gen" } roc_reporting = { path = "../reporting" } 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! -bumpalo = { version = "3.2", features = ["collections"] } +bumpalo = { version = "3.6.1", features = ["collections"] } inlinable_string = "0.1.0" libloading = "0.6" tempfile = "3.1.0" diff --git a/compiler/can/Cargo.toml b/compiler/can/Cargo.toml index c497ed76ebf..d196ac93433 100644 --- a/compiler/can/Cargo.toml +++ b/compiler/can/Cargo.toml @@ -16,7 +16,7 @@ roc_builtins = { path = "../builtins" } ven_graph = { path = "../../vendor/pathfinding" } 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! -bumpalo = { version = "3.2", features = ["collections"] } +bumpalo = { version = "3.6.1", features = ["collections"] } inlinable_string = "0.1" [dev-dependencies] diff --git a/compiler/collections/Cargo.toml b/compiler/collections/Cargo.toml index c2717569064..04dee2c3b5d 100644 --- a/compiler/collections/Cargo.toml +++ b/compiler/collections/Cargo.toml @@ -9,4 +9,4 @@ edition = "2018" 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.2", features = ["collections"] } +bumpalo = { version = "3.6.1", features = ["collections"] } diff --git a/compiler/fmt/Cargo.toml b/compiler/fmt/Cargo.toml index 967c0e0edd7..84777e449d5 100644 --- a/compiler/fmt/Cargo.toml +++ b/compiler/fmt/Cargo.toml @@ -12,7 +12,7 @@ roc_module = { path = "../module" } roc_parse = { path = "../parse" } 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! -bumpalo = { version = "3.2", features = ["collections"] } +bumpalo = { version = "3.6.1", features = ["collections"] } inlinable_string = "0.1" [dev-dependencies] diff --git a/compiler/gen/Cargo.toml b/compiler/gen/Cargo.toml index cd1420de3fd..ba5203cc318 100644 --- a/compiler/gen/Cargo.toml +++ b/compiler/gen/Cargo.toml @@ -17,7 +17,7 @@ roc_solve = { path = "../solve" } roc_mono = { path = "../mono" } 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! -bumpalo = { version = "3.2", features = ["collections"] } +bumpalo = { version = "3.6.1", features = ["collections"] } inlinable_string = "0.1" either = "1.6.1" # NOTE: rtfeldman/inkwell is a fork of TheDan64/inkwell which does not change anything. @@ -53,5 +53,5 @@ indoc = "0.3.3" quickcheck = "0.8" quickcheck_macros = "0.8" tokio = { version = "0.2", features = ["blocking", "fs", "sync", "rt-threaded"] } -bumpalo = { version = "3.2", features = ["collections"] } +bumpalo = { version = "3.6.1", features = ["collections"] } libc = "0.2" diff --git a/compiler/gen_dev/Cargo.toml b/compiler/gen_dev/Cargo.toml index 44b54c7fa05..b004a81d725 100644 --- a/compiler/gen_dev/Cargo.toml +++ b/compiler/gen_dev/Cargo.toml @@ -19,7 +19,7 @@ roc_solve = { path = "../solve" } roc_mono = { path = "../mono" } 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! -bumpalo = { version = "3.2", features = ["collections"] } +bumpalo = { version = "3.6.1", features = ["collections"] } inlinable_string = "0.1" target-lexicon = "0.10" libloading = "0.6" @@ -37,7 +37,7 @@ indoc = "0.3.3" quickcheck = "0.8" quickcheck_macros = "0.8" tokio = { version = "0.2", features = ["blocking", "fs", "sync", "rt-threaded"] } -bumpalo = { version = "3.2", features = ["collections"] } +bumpalo = { version = "3.6.1", features = ["collections"] } libc = "0.2" tempfile = "3.1.0" itertools = "0.9" diff --git a/compiler/load/Cargo.toml b/compiler/load/Cargo.toml index 8166778d9d0..169b50367ce 100644 --- a/compiler/load/Cargo.toml +++ b/compiler/load/Cargo.toml @@ -20,7 +20,7 @@ roc_solve = { path = "../solve" } roc_mono = { path = "../mono" } roc_reporting = { path = "../reporting" } ven_pretty = { path = "../../vendor/pretty" } -bumpalo = { version = "3.2", features = ["collections"] } +bumpalo = { version = "3.6.1", features = ["collections"] } inlinable_string = "0.1" parking_lot = { version = "0.11", features = ["deadlock_detection"] } crossbeam = "0.7" diff --git a/compiler/module/Cargo.toml b/compiler/module/Cargo.toml index aee0adf252e..545c8486409 100644 --- a/compiler/module/Cargo.toml +++ b/compiler/module/Cargo.toml @@ -8,7 +8,7 @@ license = "Apache-2.0" [dependencies] roc_region = { path = "../region" } roc_collections = { path = "../collections" } -bumpalo = { version = "3.2", features = ["collections"] } +bumpalo = { version = "3.6.1", features = ["collections"] } inlinable_string = "0.1" lazy_static = "1.4" diff --git a/compiler/mono/Cargo.toml b/compiler/mono/Cargo.toml index 7757a65b6c4..49d240ca8d0 100644 --- a/compiler/mono/Cargo.toml +++ b/compiler/mono/Cargo.toml @@ -15,7 +15,7 @@ roc_unify = { path = "../unify" } roc_solve = { path = "../solve" } roc_problem = { path = "../problem" } ven_pretty = { path = "../../vendor/pretty" } -bumpalo = { version = "3.2", features = ["collections"] } +bumpalo = { version = "3.6.1", features = ["collections"] } ven_ena = { path = "../../vendor/ena" } linked-hash-map = "0.5.4" diff --git a/compiler/parse/Cargo.toml b/compiler/parse/Cargo.toml index ac1feadd437..0ad4bcdc7db 100644 --- a/compiler/parse/Cargo.toml +++ b/compiler/parse/Cargo.toml @@ -9,7 +9,7 @@ edition = "2018" roc_collections = { path = "../collections" } roc_region = { path = "../region" } roc_module = { path = "../module" } -bumpalo = { version = "3.2", features = ["collections"] } +bumpalo = { version = "3.6.1", features = ["collections"] } inlinable_string = "0.1" encode_unicode = "0.3" diff --git a/compiler/parse/fuzz/Cargo.toml b/compiler/parse/fuzz/Cargo.toml index 2b60a1683e3..792dae33292 100644 --- a/compiler/parse/fuzz/Cargo.toml +++ b/compiler/parse/fuzz/Cargo.toml @@ -11,7 +11,7 @@ cargo-fuzz = true [dependencies] libfuzzer-sys = "0.3" -bumpalo = { version = "3.2", features = ["collections"] } +bumpalo = { version = "3.6.1", features = ["collections"] } [dependencies.roc_parse] path = ".." diff --git a/compiler/reporting/Cargo.toml b/compiler/reporting/Cargo.toml index 16ebd241ff5..0910e3bbc50 100644 --- a/compiler/reporting/Cargo.toml +++ b/compiler/reporting/Cargo.toml @@ -20,7 +20,7 @@ inlinable_string = "0.1" 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! distance = "0.4.0" -bumpalo = { version = "3.2", features = ["collections"] } +bumpalo = { version = "3.6.1", features = ["collections"] } [dev-dependencies] roc_constrain = { path = "../constrain" } diff --git a/compiler/solve/Cargo.toml b/compiler/solve/Cargo.toml index b9cd068fbff..ae89a64eee0 100644 --- a/compiler/solve/Cargo.toml +++ b/compiler/solve/Cargo.toml @@ -25,4 +25,4 @@ indoc = "0.3.3" tempfile = "3.1.0" quickcheck = "0.8" quickcheck_macros = "0.8" -bumpalo = { version = "3.2", features = ["collections"] } +bumpalo = { version = "3.6.1", features = ["collections"] } diff --git a/compiler/str/Cargo.toml b/compiler/str/Cargo.toml index aa96d3e20a2..3bb0ca3b47e 100644 --- a/compiler/str/Cargo.toml +++ b/compiler/str/Cargo.toml @@ -13,7 +13,7 @@ roc_types = { path = "../types" } roc_can = { path = "../can" } roc_unify = { path = "../unify" } roc_problem = { path = "../problem" } -bumpalo = { version = "3.2", features = ["collections"] } +bumpalo = { version = "3.6.1", features = ["collections"] } [dev-dependencies] roc_constrain = { path = "../constrain" } diff --git a/compiler/test_gen/Cargo.toml b/compiler/test_gen/Cargo.toml index 2a2d57c5e10..af542530032 100644 --- a/compiler/test_gen/Cargo.toml +++ b/compiler/test_gen/Cargo.toml @@ -25,7 +25,7 @@ roc_build = { path = "../build" } roc_std = { path = "../../roc_std" } 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! -bumpalo = { version = "3.2", features = ["collections"] } +bumpalo = { version = "3.6.1", features = ["collections"] } inlinable_string = "0.1" either = "1.6.1" indoc = "0.3.3" @@ -58,4 +58,4 @@ maplit = "1.0.1" quickcheck = "0.8" quickcheck_macros = "0.8" tokio = { version = "0.2", features = ["blocking", "fs", "sync", "rt-threaded"] } -bumpalo = { version = "3.2", features = ["collections"] } +bumpalo = { version = "3.6.1", features = ["collections"] } diff --git a/editor/Cargo.toml b/editor/Cargo.toml index d20bfaf82c0..1ed3ce17baa 100644 --- a/editor/Cargo.toml +++ b/editor/Cargo.toml @@ -23,7 +23,7 @@ roc_solve = { path = "../compiler/solve" } ven_graph = { path = "../vendor/pathfinding" } im = "15" # im and im-rc should always have the same version! im-rc = "15" # im and im-rc should always have the same version! -bumpalo = { version = "3.2", features = ["collections"] } +bumpalo = { version = "3.6.1", features = ["collections"] } inlinable_string = "0.1" arraystring = "0.3.0" libc = "0.2" From cdf5b89f9a50b32553a9ead3d610702f037ded12 Mon Sep 17 00:00:00 2001 From: Folkert Date: Sun, 18 Apr 2021 15:35:43 +0200 Subject: [PATCH 2/2] using hashbrown + bumpalo in practice --- Cargo.lock | 29 ++++++++++++++++++++++++++--- compiler/collections/Cargo.toml | 1 + compiler/collections/src/all.rs | 2 ++ compiler/mono/Cargo.toml | 1 + compiler/mono/src/ir.rs | 14 +++++++++----- 5 files changed, 39 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3f45501c796..952d4d2bc16 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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", diff --git a/compiler/collections/Cargo.toml b/compiler/collections/Cargo.toml index 04dee2c3b5d..060747e78a8 100644 --- a/compiler/collections/Cargo.toml +++ b/compiler/collections/Cargo.toml @@ -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" ] } diff --git a/compiler/collections/src/all.rs b/compiler/collections/src/all.rs index 18cd19f554b..a50a8febcba 100644 --- a/compiler/collections/src/all.rs +++ b/compiler/collections/src/all.rs @@ -28,6 +28,8 @@ pub type SendMap = im::hashmap::HashMap; pub type SendSet = im::hashset::HashSet; +pub type BumpMap<'a, K, V> = hashbrown::HashMap>; + pub fn arena_join<'a, I>(arena: &'a Bump, strings: &mut I, join_str: &str) -> String<'a> where I: Iterator, diff --git a/compiler/mono/Cargo.toml b/compiler/mono/Cargo.toml index 49d240ca8d0..2123562c9a0 100644 --- a/compiler/mono/Cargo.toml +++ b/compiler/mono/Cargo.toml @@ -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" diff --git a/compiler/mono/src/ir.rs b/compiler/mono/src/ir.rs index 1957cfaa2f9..00202f42a25 100644 --- a/compiler/mono/src/ir.rs +++ b/compiler/mono/src/ir.rs @@ -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>, - aliases: MutMap>, + 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, } };