Skip to content

Commit 2c6f9bd

Browse files
use mimalloc on native
1 parent d1d09fe commit 2c6f9bd

File tree

4 files changed

+68
-32
lines changed

4 files changed

+68
-32
lines changed

Cargo.lock

Lines changed: 59 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ rand = { version = "0.9", default-features = false, features = ["small_rng"] }
2121
# native:
2222
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
2323
env_logger = { version = "0.11", optional = true }
24-
25-
26-
[features]
27-
logs = ["dep:env_logger"]
24+
mimalloc = { version = "0.1" }
2825

2926
# web:
3027
[target.'cfg(target_arch = "wasm32")'.dependencies]
3128
wgpu = { version = "24", features = ["webgl"] }
3229
wasm-bindgen-futures = "0.4"
3330
web-sys = "0.3" # to access the DOM (to hide the loading text)
3431

32+
[features]
33+
logs = ["dep:env_logger"]
34+
3535
[profile.release]
3636
codegen-units = 1 # Allows LLVM to perform better optimization.
3737
lto = true # Enables link-time-optimizations.

src/main.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
22

3+
#[cfg(not(target_arch = "wasm32"))]
4+
#[global_allocator]
5+
static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
6+
37
// When compiling natively:
48
#[cfg(not(target_arch = "wasm32"))]
59
fn main() -> eframe::Result {

src/simulation/cpu.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl ParticleSimulation for CpuParticleSimulation {
3838
if self.paused {
3939
return;
4040
}
41-
// Update particles on CPU
41+
// TODO: Make this parallel
4242
for particle in &mut self.particles[0..self.particle_count as usize] {
4343
// Apply gravity
4444
let mut velocity = Vec3::from(particle.velocity);

0 commit comments

Comments
 (0)