From 6b2617397da51a6e639e1754248611a5c12027c5 Mon Sep 17 00:00:00 2001 From: kpbaks Date: Tue, 28 May 2024 13:24:35 +0200 Subject: [PATCH] feat: add mimalloc as global allocator --- .gitignore | 2 ++ Cargo.lock | 20 ++++++++++++++++++++ crates/gbpplanner-rs/Cargo.toml | 1 + crates/gbpplanner-rs/src/export.rs | 8 ++++---- crates/gbpplanner-rs/src/main.rs | 4 ++++ crates/gbpplanner-rs/src/ui/settings.rs | 6 +++--- flake.nix | 1 + scripts/run-circle-expertiment.fish | 2 +- 8 files changed, 36 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 4b9e4da4..47c0fdb8 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,5 @@ flamegraphs/* *.json !results/*.json + +*.html diff --git a/Cargo.lock b/Cargo.lock index ac138237..ae7c96c8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3575,6 +3575,7 @@ dependencies = [ "itertools 0.13.0", "iyes_perf_ui", "leafwing-input-manager", + "mimalloc", "min_len_vec", "ndarray", "ndarray-inverse", @@ -4454,6 +4455,16 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" +[[package]] +name = "libmimalloc-sys" +version = "0.1.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e7bb23d733dfcc8af652a78b7bf232f0e967710d044732185e561e47c0336b6" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "libredox" version = "0.0.2" @@ -4665,6 +4676,15 @@ dependencies = [ "paste", ] +[[package]] +name = "mimalloc" +version = "0.1.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9186d86b79b52f4a77af65604b51225e8db1d6ee7e3f41aec1e40829c71a176" +dependencies = [ + "libmimalloc-sys", +] + [[package]] name = "mime" version = "0.3.17" diff --git a/crates/gbpplanner-rs/Cargo.toml b/crates/gbpplanner-rs/Cargo.toml index dbbd7674..8ce640a0 100644 --- a/crates/gbpplanner-rs/Cargo.toml +++ b/crates/gbpplanner-rs/Cargo.toml @@ -150,6 +150,7 @@ serde_json = "1.0.116" colorgrad = "0.6.2" # open = "5.1.0" ordered-float = "4.2.0" +mimalloc = "0.1.42" # dialoguer = { version = "0.11.0", features = ["fuzzy-select"] } # # TODO: change to not wasm diff --git a/crates/gbpplanner-rs/src/export.rs b/crates/gbpplanner-rs/src/export.rs index b155e1b3..bc884885 100644 --- a/crates/gbpplanner-rs/src/export.rs +++ b/crates/gbpplanner-rs/src/export.rs @@ -25,10 +25,10 @@ impl Plugin for ExportPlugin { .add_event::() .init_resource::() .init_resource::() - .add_systems( - FixedUpdate, - send_default_export_event.run_if(once_after_delay(Duration::from_secs(60))), - ) + // .add_systems( + // FixedUpdate, + // send_default_export_event.run_if(once_after_delay(Duration::from_secs(60))), + // ) .add_systems( Update, ( diff --git a/crates/gbpplanner-rs/src/main.rs b/crates/gbpplanner-rs/src/main.rs index 5d04b111..63b30447 100644 --- a/crates/gbpplanner-rs/src/main.rs +++ b/crates/gbpplanner-rs/src/main.rs @@ -30,6 +30,10 @@ pub(crate) mod macros; #[global_allocator] static ALLOC: dhat::Alloc = dhat::Alloc; +#[cfg(not(feature = "dhat-heap"))] +#[global_allocator] +static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc; + use std::path::Path; use bevy::{ diff --git a/crates/gbpplanner-rs/src/ui/settings.rs b/crates/gbpplanner-rs/src/ui/settings.rs index dc25c729..0bd1a54c 100644 --- a/crates/gbpplanner-rs/src/ui/settings.rs +++ b/crates/gbpplanner-rs/src/ui/settings.rs @@ -439,7 +439,7 @@ fn ui_settings_panel( ui.separator(); // ui.label("Factors"); - ui.label(egui::RichText::new("Factors").size(16.0)); + ui.label(egui::RichText::new("Factors Enabled").size(16.0)); custom::grid("factors_enabled_grid", 2).show(ui, |ui| { let copy = config.gbp.factors_enabled.clone(); @@ -474,7 +474,7 @@ fn ui_settings_panel( // ui.spacing_mut().slider_width = ui.available_width() - (custom::SLIDER_EXTRA_WIDE + custom::SPACING); ui.spacing_mut().slider_width = ui.available_width(); // let mut available_size = ui.available_size(); - // available_size.x += 10.0; + // available_size.x += 10.0; // let slider_response = ui.add_sized(available_size, let slider_response = ui.add_enabled( time_virtual.is_paused(), @@ -903,7 +903,7 @@ fn ui_settings_panel( }); ui.end_row(); - ui.label("Exit when scenario finishes"); + ui.label("Exit at End"); custom::float_right(ui, |ui| { custom::toggle_ui(ui, &mut config.simulation.exit_application_on_scenario_finished); }); diff --git a/flake.nix b/flake.nix index dd623cf7..58f8cadd 100644 --- a/flake.nix +++ b/flake.nix @@ -63,6 +63,7 @@ cargo-pgo cargo-flamegraph cargo-license + cargo-release # cargo-tree # # cargo-profiler diff --git a/scripts/run-circle-expertiment.fish b/scripts/run-circle-expertiment.fish index b95d45fa..59b64b32 100755 --- a/scripts/run-circle-expertiment.fish +++ b/scripts/run-circle-expertiment.fish @@ -18,7 +18,7 @@ end printf '%sinfo%s: starting experiment\n' (set_color green) (set_color normal) >&2 -for seed in 0 31 227 252 805 +for seed in 0 # 31 227 252 805 sed --regexp-extended "s/prng-seed\s*=\s*([0-9]+)/prng-seed = $seed/" -i $config_file for num_robots in (seq 5 5 50) sed --regexp-extended "s/robots:\s+(\d+)/robots: $num_robots/" -i $formation_file