Skip to content

Commit

Permalink
perf: incremental code splitting
Browse files Browse the repository at this point in the history
  • Loading branch information
JSerFeng committed Oct 9, 2024
1 parent aa906a7 commit 6111dc5
Show file tree
Hide file tree
Showing 21 changed files with 1,532 additions and 642 deletions.
28 changes: 28 additions & 0 deletions .vscode/rspack.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"folders": [
{
"path": ".."
},
{
"path": "../../../demo/webpack"
},
{
"path": "../../webpack"
}
],
"settings": {
"git.ignoreLimitWarning": true,
"rust-analyzer.procMacro.enable": true,
"rust-analyzer.procMacro.attributes.enable": true,
"rust-analyzer.linkedProjects": [
"Cargo.toml",
"crates/node_binding/Cargo.toml",
"./crates/rspack_plugin_ensure_chunk_conditions/Cargo.toml"
],
"files.associations": {
"*.snap": "markdown",
"*.snap.txt": "markdown",
"*.json": "jsonc"
}
}
}
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ panic = "abort"

[profile.release]
codegen-units = 1
debug = false
debug = true
# Performs “thin” LTO. This is similar to “fat”, but takes substantially less time to run while still achieving performance gains similar to “fat”.
lto = "thin"
opt-level = 3
panic = "abort"
strip = true
strip = false

[profile.release-prod]
inherits = "release"
Expand Down
19 changes: 19 additions & 0 deletions crates/rspack_collections/src/ukey.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ where
self.inner.entry(id)
}

pub fn get(&self, id: &<Item as DatabaseItem>::ItemUkey) -> Option<&Item> {
self.inner.get(id)
}

pub fn get_mut(&mut self, id: &<Item as DatabaseItem>::ItemUkey) -> Option<&mut Item> {
self.inner.get_mut(id)
}

pub fn expect_get(&self, id: &<Item as DatabaseItem>::ItemUkey) -> &Item {
self
.inner
Expand Down Expand Up @@ -235,3 +243,14 @@ where
self.inner.entry(ukey).or_insert(item)
}
}

impl<Item: DatabaseItem> Database<Item>
where
<Item as DatabaseItem>::ItemUkey: Eq + Ord + Hash + Debug,
{
pub fn ordered_keys(&self) -> Vec<&<Item as DatabaseItem>::ItemUkey> {
let mut keys = self.keys().collect::<Vec<_>>();
keys.sort();
keys
}
}
Loading

0 comments on commit 6111dc5

Please sign in to comment.