-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test of memory use when logging a lot of big images (#1372)
* Add a test of memory use when logging a lot of big images * copy-pasta Co-authored-by: Clement Rey <[email protected]> * copy-pasta Co-authored-by: Clement Rey <[email protected]> * Add store archiving to the stack shortening * fix feature name --------- Co-authored-by: Clement Rey <[email protected]>
- Loading branch information
Showing
16 changed files
with
105 additions
and
9 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
[workspace] | ||
resolver = "2" | ||
members = ["crates/*", "examples/rust/*", "rerun_py", "run_wasm"] | ||
members = [ | ||
"crates/*", | ||
"examples/rust/*", | ||
"rerun_py", | ||
"run_wasm", | ||
"tests/rust/*", | ||
] | ||
|
||
[workspace.package] | ||
authors = ["rerun.io <[email protected]>"] | ||
|
@@ -56,6 +62,7 @@ half = "2.0" | |
image = "0.24" | ||
lazy_static = "1.4" | ||
macaw = "0.18" | ||
mimalloc = "0.1.29" | ||
ndarray = "0.15" | ||
polars-core = "0.27.1" | ||
polars-lazy = "0.27.1" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Uses of the rerun SDK designed to test different things. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[package] | ||
name = "test_image_memory" | ||
version.workspace = true | ||
edition.workspace = true | ||
rust-version.workspace = true | ||
license.workspace = true | ||
publish = false | ||
|
||
[dependencies] | ||
rerun.workspace = true | ||
re_format.workspace = true | ||
|
||
mimalloc.workspace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
//! Logs a bunch of big images to test Rerun memory usage. | ||
use mimalloc::MiMalloc; | ||
use re_memory::AccountingAllocator; | ||
use rerun::external::{image, re_memory, re_viewer}; | ||
|
||
#[global_allocator] | ||
static GLOBAL: AccountingAllocator<MiMalloc> = AccountingAllocator::new(MiMalloc); | ||
|
||
fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
re_memory::accounting_allocator::turn_on_tracking_if_env_var( | ||
re_viewer::env_vars::RERUN_TRACK_ALLOCATIONS, | ||
); | ||
|
||
let session = rerun::Session::init("test_image_memory_rs", true); | ||
|
||
session.spawn(|mut session| { | ||
log_images(&mut session).unwrap(); | ||
})?; | ||
|
||
Ok(()) | ||
} | ||
|
||
fn log_images(session: &mut rerun::Session) -> Result<(), Box<dyn std::error::Error>> { | ||
let (w, h) = (2048, 1024); | ||
let n = 100; | ||
|
||
let image = image::RgbaImage::from_fn(w, h, |x, y| { | ||
if (x + y) % 2 == 0 { | ||
image::Rgba([0, 0, 0, 255]) | ||
} else { | ||
image::Rgba([255, 255, 255, 255]) | ||
} | ||
}); | ||
let tensor = rerun::components::Tensor::from_image(image)?; | ||
|
||
for _ in 0..n { | ||
rerun::MsgSender::new("image") | ||
.with_component(&[tensor.clone()])? | ||
.send(session)?; | ||
} | ||
|
||
eprintln!( | ||
"Logged {n} {w}x{h} RGBA images = {}", | ||
re_format::format_bytes((n * w * h * 4) as _) | ||
); | ||
|
||
// Give viewer time to load it: | ||
std::thread::sleep(std::time::Duration::from_secs(2)); | ||
|
||
if let Some(allocs) = re_memory::accounting_allocator::global_allocs() { | ||
eprintln!("{} RAM used", re_format::format_bytes(allocs.size as _)); | ||
} | ||
|
||
Ok(()) | ||
} |