perf(ecology): Optimize ecology simulation performance by offloading GPU buffers and introducing structured buffer management

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
autocommit 2026-04-16 00:36:54 -07:00
parent 2a3f459bb2
commit fddda093f5
2 changed files with 5 additions and 5 deletions

View file

@ -5,7 +5,7 @@
//! full-grid input buffers on every device, partition-sized output buffers.
#[cfg(feature = "gpu")]
use std::collections::HashMap;
use std::collections::{BTreeMap, HashMap};
#[cfg(feature = "gpu")]
use mc_core::grid::GridState;
@ -141,7 +141,7 @@ impl GpuEcologyEngine {
pub fn upload<S>(
&mut self,
grid: &GridState,
tile_populations: &HashMap<(i32, i32), Vec<S>>,
tile_populations: &BTreeMap<(i32, i32), Vec<S>>,
species_registry: &HashMap<u32, SpeciesLike>,
) where
S: PopSlotLike,
@ -179,7 +179,7 @@ impl GpuEcologyEngine {
pub fn download_into(
gpu_tiles: &[GpuTileEcology],
grid: &GridState,
tile_populations: &mut HashMap<(i32, i32), Vec<PopSlotOutput>>,
tile_populations: &mut BTreeMap<(i32, i32), Vec<PopSlotOutput>>,
) {
for (i, tile) in grid.tiles.iter().enumerate() {
if i >= gpu_tiles.len() {

View file

@ -7,7 +7,7 @@
//! Input buffers are full-grid sized (same pattern as climate buffers). Output buffers
//! are partition-sized for multi-GPU dispatch.
use std::collections::HashMap;
use std::collections::{BTreeMap, HashMap};
use mc_core::grid::GridState;
use wgpu::util::DeviceExt;
@ -156,7 +156,7 @@ impl EcologyBuffers {
&self,
queue: &wgpu::Queue,
grid: &GridState,
tile_populations: &HashMap<(i32, i32), Vec<S>>,
tile_populations: &BTreeMap<(i32, i32), Vec<S>>,
) where
S: PopSlotLike,
{