Skip to content

Commit

Permalink
New option to disable persistent storage (#1825)
Browse files Browse the repository at this point in the history
* New option to disable persistent storage
  • Loading branch information
jleibs authored Apr 12, 2023
1 parent 48fda31 commit 668e56d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 4 deletions.
15 changes: 11 additions & 4 deletions crates/re_viewer/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ enum TimeControlCommand {
#[derive(Clone, Copy, Default)]
pub struct StartupOptions {
pub memory_limit: re_memory::MemoryLimit,
pub persist_state: bool,
}

// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -118,9 +119,13 @@ impl App {
);
}

let state: AppState = storage
.and_then(|storage| eframe::get_value(storage, eframe::APP_KEY))
.unwrap_or_default();
let state: AppState = if startup_options.persist_state {
storage
.and_then(|storage| eframe::get_value(storage, eframe::APP_KEY))
.unwrap_or_default()
} else {
AppState::default()
};

let mut analytics = ViewerAnalytics::new();
analytics.on_viewer_started(&build_info, app_env);
Expand Down Expand Up @@ -412,7 +417,9 @@ impl eframe::App for App {
}

fn save(&mut self, storage: &mut dyn eframe::Storage) {
eframe::set_value(storage, eframe::APP_KEY, &self.state);
if self.startup_options.persist_state {
eframe::set_value(storage, eframe::APP_KEY, &self.state);
}
}

fn update(&mut self, egui_ctx: &egui::Context, frame: &mut eframe::Frame) {
Expand Down
22 changes: 22 additions & 0 deletions crates/re_viewer/src/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ pub async fn start(
Box::new(move |cc| {
let build_info = re_build_info::build_info!();
let app_env = crate::AppEnvironment::Web;
let persist_state = get_persist_state(&cc.integration_info);
let startup_options = crate::StartupOptions {
memory_limit: re_memory::MemoryLimit {
// On wasm32 we only have 4GB of memory to play around with.
limit: Some(3_500_000_000),
},
persist_state,
};
let re_ui = crate::customize_eframe(cc);
let url = url.unwrap_or_else(|| get_url(&cc.integration_info));
Expand Down Expand Up @@ -122,3 +124,23 @@ fn get_url(info: &eframe::IntegrationInfo) -> String {
url
}
}

fn get_persist_state(info: &eframe::IntegrationInfo) -> bool {
match info
.web_info
.location
.query_map
.get("persist")
.map(String::as_str)
{
Some("0") => false,
Some("1") => true,
Some(other) => {
re_log::warn!(
"Unexpected value for 'persist' query: {other:?}. Expected either '0' or '1'. Defaulting to '1'."
);
true
}
_ => true,
}
}
10 changes: 10 additions & 0 deletions crates/rerun/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@ struct Args {
#[clap(long)]
memory_limit: Option<String>,

/// Whether the Rerun Viewer should persist the state of the viewer to disk.
///
/// When persisted, the state will be stored at the following locations:
/// - Linux: /home/UserName/.local/share/rerunviewer
/// - macOS: /Users/UserName/Library/Application Support/rerunviewer
/// - Windows: C:\Users\UserName\AppData\Roaming\rerunviewer
#[clap(long, default_value_t = true)]
persist_state: bool,

/// What TCP port do we listen to (for SDK:s to connect to)?
#[cfg(feature = "server")]
#[clap(long, default_value_t = re_sdk_comms::DEFAULT_SERVER_PORT)]
Expand Down Expand Up @@ -273,6 +282,7 @@ async fn run_impl(
re_memory::MemoryLimit::parse(l)
.unwrap_or_else(|err| panic!("Bad --memory-limit: {err}"))
}),
persist_state: args.persist_state,
};

let (shutdown_rx, shutdown_bool) = setup_ctrl_c_handler();
Expand Down

2 comments on commit 668e56d

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rust Benchmark

Benchmark suite Current: 668e56d Previous: 48fda31 Ratio
datastore/num_rows=1000/num_instances=1000/packed=false/insert/default 15784730 ns/iter (± 470697) 11228273 ns/iter (± 812628) 1.41
datastore/num_rows=1000/num_instances=1000/packed=false/latest_at/default 1833 ns/iter (± 21) 1823 ns/iter (± 74) 1.01
datastore/num_rows=1000/num_instances=1000/packed=false/latest_at_missing/primary/default 282 ns/iter (± 0) 281 ns/iter (± 0) 1.00
datastore/num_rows=1000/num_instances=1000/packed=false/latest_at_missing/secondaries/default 434 ns/iter (± 0) 437 ns/iter (± 1) 0.99
datastore/num_rows=1000/num_instances=1000/packed=false/range/default 16427989 ns/iter (± 570498) 11439964 ns/iter (± 810756) 1.44
mono_points_arrow/generate_message_bundles 50577851 ns/iter (± 476219) 47785835 ns/iter (± 1584247) 1.06
mono_points_arrow/generate_messages 167165236 ns/iter (± 1480358) 171529524 ns/iter (± 1267367) 0.97
mono_points_arrow/encode_log_msg 203452964 ns/iter (± 2078519) 195031260 ns/iter (± 1103309) 1.04
mono_points_arrow/encode_total 415091277 ns/iter (± 3535533) 414147454 ns/iter (± 2379197) 1.00
mono_points_arrow/decode_log_msg 250160700 ns/iter (± 1397692) 249335693 ns/iter (± 1087905) 1.00
mono_points_arrow/decode_message_bundles 82479745 ns/iter (± 842146) 82213943 ns/iter (± 1151686) 1.00
mono_points_arrow/decode_total 335671568 ns/iter (± 2001461) 339710525 ns/iter (± 1811257) 0.99
mono_points_arrow_batched/generate_message_bundles 46004409 ns/iter (± 571466) 40700771 ns/iter (± 2150736) 1.13
mono_points_arrow_batched/generate_messages 13015435 ns/iter (± 525198) 8195770 ns/iter (± 697903) 1.59
mono_points_arrow_batched/encode_log_msg 1506896 ns/iter (± 12098) 1486544 ns/iter (± 2711) 1.01
mono_points_arrow_batched/encode_total 59279349 ns/iter (± 1198647) 50519647 ns/iter (± 2009442) 1.17
mono_points_arrow_batched/decode_log_msg 871468 ns/iter (± 4810) 859989 ns/iter (± 3806) 1.01
mono_points_arrow_batched/decode_message_bundles 17341229 ns/iter (± 496480) 12023795 ns/iter (± 615393) 1.44
mono_points_arrow_batched/decode_total 17579200 ns/iter (± 515298) 12900926 ns/iter (± 637470) 1.36
batch_points_arrow/generate_message_bundles 334100 ns/iter (± 768) 337017 ns/iter (± 1002) 0.99
batch_points_arrow/generate_messages 6354 ns/iter (± 14) 6403 ns/iter (± 15) 0.99
batch_points_arrow/encode_log_msg 413505 ns/iter (± 2511) 395546 ns/iter (± 1427) 1.05
batch_points_arrow/encode_total 776396 ns/iter (± 4689) 745571 ns/iter (± 3105) 1.04
batch_points_arrow/decode_log_msg 349217 ns/iter (± 2317) 337974 ns/iter (± 1003) 1.03
batch_points_arrow/decode_message_bundles 2316 ns/iter (± 10) 2297 ns/iter (± 8) 1.01
batch_points_arrow/decode_total 354830 ns/iter (± 2627) 346191 ns/iter (± 1098) 1.02
arrow_mono_points/insert 7490876895 ns/iter (± 47840594) 7534290665 ns/iter (± 18910437) 0.99
arrow_mono_points/query 1866013 ns/iter (± 29149) 1826729 ns/iter (± 10553) 1.02
arrow_batch_points/insert 3358790 ns/iter (± 41710) 3263899 ns/iter (± 10735) 1.03
arrow_batch_points/query 16352 ns/iter (± 32) 16463 ns/iter (± 57) 0.99
arrow_batch_vecs/insert 45901 ns/iter (± 239) 44890 ns/iter (± 93) 1.02
arrow_batch_vecs/query 395610 ns/iter (± 532) 389053 ns/iter (± 970) 1.02
tuid/Tuid::random 34 ns/iter (± 0) 34 ns/iter (± 0) 1

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Rust Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.50.

Benchmark suite Current: 668e56d Previous: 48fda31 Ratio
mono_points_arrow_batched/generate_messages 13015435 ns/iter (± 525198) 8195770 ns/iter (± 697903) 1.59

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.