Skip to content

Commit

Permalink
perf: Use ahash instead of sip hash (#2073)
Browse files Browse the repository at this point in the history
swc_common:
 - Add `AHashMap`.
 - Add `AHashSet`.
  • Loading branch information
kdy1 authored Aug 14, 2021
1 parent b0c41bb commit f6aabfc
Show file tree
Hide file tree
Showing 50 changed files with 324 additions and 318 deletions.
55 changes: 28 additions & 27 deletions Cargo.lock

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

34 changes: 17 additions & 17 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2018"
license = "Apache-2.0/MIT"
name = "swc"
repository = "https://github.com/swc-project/swc.git"
version = "0.40.0"
version = "0.40.1"

[lib]
name = "swc"
Expand All @@ -30,33 +30,33 @@ serde = {version = "1", features = ["derive"]}
serde_json = "1"
sourcemap = "6"
swc_atoms = {version = "0.2", path = "./atoms"}
swc_bundler = {version = "0.52.0", path = "./bundler"}
swc_common = {version = "0.11.0", path = "./common", features = ["sourcemap", "concurrent"]}
swc_ecma_ast = {version = "0.49.0", path = "./ecmascript/ast"}
swc_ecma_codegen = {version = "0.66.0", path = "./ecmascript/codegen"}
swc_ecma_ext_transforms = {version = "0.24.0", path = "./ecmascript/ext-transforms"}
swc_ecma_loader = {version = "0.14.0", path = "./ecmascript/loader", features = ["lru", "node", "tsc"]}
swc_ecma_minifier = {version = "0.20.0", path = "./ecmascript/minifier"}
swc_ecma_parser = {version = "0.66.0", path = "./ecmascript/parser"}
swc_ecma_preset_env = {version = "0.36.0", path = "./ecmascript/preset-env"}
swc_ecma_transforms = {version = "0.65.0", path = "./ecmascript/transforms", features = [
swc_bundler = {version = "0.52.1", path = "./bundler"}
swc_common = {version = "0.11.6", path = "./common", features = ["sourcemap", "concurrent"]}
swc_ecma_ast = {version = "0.49.4", path = "./ecmascript/ast"}
swc_ecma_codegen = {version = "0.66.3", path = "./ecmascript/codegen"}
swc_ecma_ext_transforms = {version = "0.24.1", path = "./ecmascript/ext-transforms"}
swc_ecma_loader = {version = "0.14.1", path = "./ecmascript/loader", features = ["lru", "node", "tsc"]}
swc_ecma_minifier = {version = "0.20.1", path = "./ecmascript/minifier"}
swc_ecma_parser = {version = "0.66.4", path = "./ecmascript/parser"}
swc_ecma_preset_env = {version = "0.36.1", path = "./ecmascript/preset-env"}
swc_ecma_transforms = {version = "0.65.1", path = "./ecmascript/transforms", features = [
"compat",
"module",
"optimization",
"proposal",
"react",
"typescript",
]}
swc_ecma_transforms_base = {version = "0.26.0", path = "./ecmascript/transforms/base"}
swc_ecma_utils = {version = "0.41.0", path = "./ecmascript/utils"}
swc_ecma_visit = {version = "0.35.0", path = "./ecmascript/visit"}
swc_ecmascript = {version = "0.55.0", path = "./ecmascript"}
swc_node_base = {version = "0.2.0", path = "./node/base"}
swc_ecma_transforms_base = {version = "0.26.3", path = "./ecmascript/transforms/base"}
swc_ecma_utils = {version = "0.41.2", path = "./ecmascript/utils"}
swc_ecma_visit = {version = "0.35.2", path = "./ecmascript/visit"}
swc_ecmascript = {version = "0.55.1", path = "./ecmascript"}
swc_node_base = {version = "0.2.2", path = "./node/base"}
swc_visit = {version = "0.2.3", path = "./visit"}

[dev-dependencies]
rayon = "1"
testing = {version = "0.12.0", path = "./testing"}
testing = {version = "0.12.2", path = "./testing"}
walkdir = "2"

[[example]]
Expand Down
22 changes: 11 additions & 11 deletions bundler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ include = ["Cargo.toml", "build.rs", "src/**/*.rs", "src/**/*.js"]
license = "Apache-2.0/MIT"
name = "swc_bundler"
repository = "https://github.com/swc-project/swc.git"
version = "0.52.0"
version = "0.52.1"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
Expand All @@ -32,22 +32,22 @@ rayon = {version = "1", optional = true}
relative-path = "1.2"
retain_mut = "0.1.2"
swc_atoms = {version = "0.2.4", path = "../atoms"}
swc_common = {version = "0.11.0", path = "../common"}
swc_ecma_ast = {version = "0.49.0", path = "../ecmascript/ast"}
swc_ecma_codegen = {version = "0.66.0", path = "../ecmascript/codegen"}
swc_ecma_loader = {version = "0.14.0", path = "../ecmascript/loader"}
swc_ecma_parser = {version = "0.66.0", path = "../ecmascript/parser"}
swc_ecma_transforms = {version = "0.65.0", path = "../ecmascript/transforms", features = ["optimization"]}
swc_ecma_utils = {version = "0.41.0", path = "../ecmascript/utils"}
swc_ecma_visit = {version = "0.35.0", path = "../ecmascript/visit"}
swc_common = {version = "0.11.6", path = "../common"}
swc_ecma_ast = {version = "0.49.4", path = "../ecmascript/ast"}
swc_ecma_codegen = {version = "0.66.3", path = "../ecmascript/codegen"}
swc_ecma_loader = {version = "0.14.1", path = "../ecmascript/loader"}
swc_ecma_parser = {version = "0.66.4", path = "../ecmascript/parser"}
swc_ecma_transforms = {version = "0.65.1", path = "../ecmascript/transforms", features = ["optimization"]}
swc_ecma_utils = {version = "0.41.2", path = "../ecmascript/utils"}
swc_ecma_visit = {version = "0.35.2", path = "../ecmascript/visit"}

[dev-dependencies]
hex = "0.4"
ntest = "0.7.2"
reqwest = {version = "0.11.4", features = ["blocking"]}
sha-1 = "0.9"
swc_ecma_transforms = {version = "0.65.0", path = "../ecmascript/transforms", features = ["react", "typescript"]}
swc_ecma_transforms = {version = "0.65.1", path = "../ecmascript/transforms", features = ["react", "typescript"]}
tempfile = "3.1.0"
testing = {version = "0.12.0", path = "../testing"}
testing = {version = "0.12.2", path = "../testing"}
url = "2.1.1"
walkdir = "2"
5 changes: 2 additions & 3 deletions bundler/src/id.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use std::{
collections::HashMap,
fmt,
sync::atomic::{AtomicU32, Ordering::SeqCst},
};
use swc_atoms::JsWord;
use swc_common::{sync::Lock, FileName, Mark, SyntaxContext, DUMMY_SP};
use swc_common::{collections::AHashMap, sync::Lock, FileName, Mark, SyntaxContext, DUMMY_SP};
use swc_ecma_ast::{Expr, Ident};
use swc_ecma_utils::ident::IdentLike;

Expand All @@ -28,7 +27,7 @@ impl fmt::Debug for ModuleId {
pub(crate) struct ModuleIdGenerator {
v: AtomicU32,
/// `(module_id, local_mark, export_mark)`
cache: Lock<HashMap<FileName, (ModuleId, Mark, Mark)>>,
cache: Lock<AHashMap<FileName, (ModuleId, Mark, Mark)>>,
}

impl ModuleIdGenerator {
Expand Down
6 changes: 2 additions & 4 deletions bundler/src/inline.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
use crate::{id::Id, modules::Modules};
use ahash::RandomState;
use std::collections::HashMap;
use swc_common::{SyntaxContext, DUMMY_SP};
use swc_common::{collections::AHashMap, SyntaxContext, DUMMY_SP};
use swc_ecma_ast::*;
use swc_ecma_visit::{
noop_visit_mut_type, noop_visit_type, Node, Visit, VisitMut, VisitMutWith, VisitWith,
};

#[derive(Debug, Default)]
pub(crate) struct InlineData {
ids: HashMap<Id, Id, RandomState>,
ids: AHashMap<Id, Id>,
}

/// Inline **injected** variables.
Expand Down
4 changes: 2 additions & 2 deletions bundler/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@ where
V: Clone,
{
#[cfg(feature = "concurrent")]
inner: dashmap::DashMap<K, V>,
inner: dashmap::DashMap<K, V, ahash::RandomState>,
#[cfg(not(feature = "concurrent"))]
inner: std::cell::RefCell<std::collections::HashMap<K, V>>,
inner: std::cell::RefCell<swc_common::collections::AHashMap<K, V>>,
}

impl<K, V> Default for CloneMap<K, V>
Expand Down
Loading

0 comments on commit f6aabfc

Please sign in to comment.