summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjetil Orbekk <kj@orbekk.com>2022-09-04 20:04:57 -0400
committerKjetil Orbekk <kj@orbekk.com>2022-09-04 20:04:57 -0400
commitb66a92fcc6120781ad5bad06c29f57fa2c919a2c (patch)
tree8d835317ef4b65bef4db9aaf153f5b29a35d0b04
parentab68d26c6b16f973642d378900f5e6ac2be221b7 (diff)
Add some release size optimizations
-rw-r--r--Cargo.lock35
-rw-r--r--webapp/Cargo.toml13
-rw-r--r--webapp/src/main.rs5
3 files changed, 48 insertions, 5 deletions
diff --git a/Cargo.lock b/Cargo.lock
index f9d3453..77361df 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -42,6 +42,12 @@ checksum = "c1ad822118d20d2c234f427000d5acc36eabe1e29a348c89b63dd60b13f28e5d"
[[package]]
name = "cfg-if"
+version = "0.1.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
+
+[[package]]
+name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
@@ -52,7 +58,7 @@ version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc"
dependencies = [
- "cfg-if",
+ "cfg-if 1.0.0",
"wasm-bindgen",
]
@@ -81,7 +87,7 @@ version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6"
dependencies = [
- "cfg-if",
+ "cfg-if 1.0.0",
"js-sys",
"libc",
"wasi",
@@ -267,7 +273,7 @@ version = "0.4.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
dependencies = [
- "cfg-if",
+ "cfg-if 1.0.0",
]
[[package]]
@@ -277,6 +283,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
[[package]]
+name = "memory_units"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8452105ba047068f40ff7093dd1d9da90898e63dd61736462e9cdda6a90ad3c3"
+
+[[package]]
name = "once_cell"
version = "1.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -518,7 +530,7 @@ version = "0.2.82"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc7652e3f6c4706c8d9cd54832c4a4ccb9b5336e2c3bd154d5cccfbf1c1f5f7d"
dependencies = [
- "cfg-if",
+ "cfg-if 1.0.0",
"wasm-bindgen-macro",
]
@@ -543,7 +555,7 @@ version = "0.4.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa76fb221a1f8acddf5b54ace85912606980ad661ac7a503b4570ffd3a624dad"
dependencies = [
- "cfg-if",
+ "cfg-if 1.0.0",
"js-sys",
"wasm-bindgen",
"web-sys",
@@ -612,10 +624,23 @@ dependencies = [
"strum",
"strum_macros",
"wasm-logger",
+ "wee_alloc",
"yew",
]
[[package]]
+name = "wee_alloc"
+version = "0.4.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dbb3b5a6b2bb17cb6ad44a2e68a43e8d2722c997da10e928665c72ec6c0a0b8e"
+dependencies = [
+ "cfg-if 0.1.10",
+ "libc",
+ "memory_units",
+ "winapi",
+]
+
+[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/webapp/Cargo.toml b/webapp/Cargo.toml
index 15a880a..1a52093 100644
--- a/webapp/Cargo.toml
+++ b/webapp/Cargo.toml
@@ -12,7 +12,20 @@ strum = "0.24"
strum_macros = "0.24"
rand = "0.8.4"
getrandom = { version = "0.2.7", features = ["js"] }
+wee_alloc = "0.4.3"
[dev-dependencies]
env_logger = "0.8.4"
dotenv = "0.15"
+
+[profile.release]
+# less code to include into binary
+panic = 'abort'
+# optimization over all codebase ( better optimization, slower build )
+codegen-units = 1
+# optimization for size ( more aggressive )
+opt-level = 'z'
+# optimization for size
+# opt-level = 's'
+# link time optimization using using whole-program analysis
+lto = true
diff --git a/webapp/src/main.rs b/webapp/src/main.rs
index 633f560..7f22b0f 100644
--- a/webapp/src/main.rs
+++ b/webapp/src/main.rs
@@ -4,6 +4,11 @@ use log::{debug, error, info, warn};
use yew::prelude::*;
pub mod card;
pub mod bridge_engine;
+extern crate wee_alloc;
+
+// Use `wee_alloc` as the global allocator.
+#[global_allocator]
+static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
fn main() {
std::panic::set_hook(Box::new(console_error_panic_hook::hook));