Skip to content

Commit

Permalink
Restore: New API to reset_time (#1826) (#1854)
Browse files Browse the repository at this point in the history
  • Loading branch information
jleibs authored Apr 14, 2023
1 parent 666c0c6 commit 8d25b9e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
16 changes: 16 additions & 0 deletions rerun_py/rerun_sdk/rerun/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,3 +528,19 @@ def set_time_nanos(timeline: str, nanos: Optional[int]) -> None:
return

bindings.set_time_nanos(timeline, nanos)


def reset_time() -> None:
"""
Clear all timeline information on this thread.
This is the same as calling `set_time_*` with `None` for all of the active timelines.
Used for all subsequent logging on the same thread,
until the next call to [`rerun.set_time_nanos`][] or [`rerun.set_time_seconds`][].
"""

if not bindings.is_enabled():
return

bindings.reset_time()
14 changes: 14 additions & 0 deletions rerun_py/src/python_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ impl ThreadInfo {
Self::with(|ti| ti.set_time(timeline, time_int));
}

pub fn reset_thread_time() {
Self::with(|ti| ti.reset_time());
}

/// Get access to the thread-local [`ThreadInfo`].
fn with<R>(f: impl FnOnce(&mut ThreadInfo) -> R) -> R {
use std::cell::RefCell;
Expand Down Expand Up @@ -92,6 +96,10 @@ impl ThreadInfo {
self.time_point.remove(&timeline);
}
}

fn reset_time(&mut self) {
self.time_point = TimePoint::default();
}
}

// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -155,6 +163,7 @@ fn rerun_bindings(py: Python<'_>, m: &PyModule) -> PyResult<()> {
m.add_function(wrap_pyfunction!(set_time_sequence, m)?)?;
m.add_function(wrap_pyfunction!(set_time_seconds, m)?)?;
m.add_function(wrap_pyfunction!(set_time_nanos, m)?)?;
m.add_function(wrap_pyfunction!(reset_time, m)?)?;

m.add_function(wrap_pyfunction!(log_unknown_transform, m)?)?;
m.add_function(wrap_pyfunction!(log_rigid3, m)?)?;
Expand Down Expand Up @@ -486,6 +495,11 @@ fn set_time_nanos(timeline: &str, ns: Option<i64>) {
);
}

#[pyfunction]
fn reset_time() {
ThreadInfo::reset_thread_time();
}

fn convert_color(color: Vec<u8>) -> PyResult<[u8; 4]> {
match &color[..] {
[r, g, b] => Ok([*r, *g, *b, 255]),
Expand Down

1 comment on commit 8d25b9e

@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: 8d25b9e Previous: b4190d8 Ratio
datastore/num_rows=1000/num_instances=1000/packed=false/insert/default 2913868 ns/iter (± 79014) 2847751 ns/iter (± 34856) 1.02
datastore/num_rows=1000/num_instances=1000/packed=false/latest_at/default 372 ns/iter (± 28) 370 ns/iter (± 2) 1.01
datastore/num_rows=1000/num_instances=1000/packed=false/latest_at_missing/primary/default 260 ns/iter (± 0) 260 ns/iter (± 0) 1
datastore/num_rows=1000/num_instances=1000/packed=false/latest_at_missing/secondaries/default 421 ns/iter (± 0) 422 ns/iter (± 0) 1.00
datastore/num_rows=1000/num_instances=1000/packed=false/range/default 2997422 ns/iter (± 47101) 2999476 ns/iter (± 28180) 1.00
datastore/num_rows=1000/num_instances=1000/gc/default 2430982 ns/iter (± 3903) 2420591 ns/iter (± 2880) 1.00
mono_points_arrow/generate_message_bundles 27361281 ns/iter (± 1123711) 26826839 ns/iter (± 744096) 1.02
mono_points_arrow/generate_messages 113812283 ns/iter (± 835795) 114183438 ns/iter (± 852589) 1.00
mono_points_arrow/encode_log_msg 144690195 ns/iter (± 2233171) 143765178 ns/iter (± 895926) 1.01
mono_points_arrow/encode_total 285260861 ns/iter (± 1624624) 289393350 ns/iter (± 1281828) 0.99
mono_points_arrow/decode_log_msg 178047417 ns/iter (± 717359) 178514877 ns/iter (± 697647) 1.00
mono_points_arrow/decode_message_bundles 60299037 ns/iter (± 987875) 59669624 ns/iter (± 798964) 1.01
mono_points_arrow/decode_total 237797991 ns/iter (± 1261283) 237518838 ns/iter (± 1321654) 1.00
mono_points_arrow_batched/generate_message_bundles 20738420 ns/iter (± 1330384) 19774388 ns/iter (± 1034473) 1.05
mono_points_arrow_batched/generate_messages 4249564 ns/iter (± 163095) 4163255 ns/iter (± 97644) 1.02
mono_points_arrow_batched/encode_log_msg 1369393 ns/iter (± 4450) 1380681 ns/iter (± 5217) 0.99
mono_points_arrow_batched/encode_total 27552349 ns/iter (± 1299622) 26578968 ns/iter (± 890823) 1.04
mono_points_arrow_batched/decode_log_msg 777435 ns/iter (± 2279) 783030 ns/iter (± 3452) 0.99
mono_points_arrow_batched/decode_message_bundles 7613252 ns/iter (± 97516) 7757235 ns/iter (± 148031) 0.98
mono_points_arrow_batched/decode_total 8422214 ns/iter (± 196503) 8510259 ns/iter (± 113219) 0.99
batch_points_arrow/generate_message_bundles 205340 ns/iter (± 22418) 193400 ns/iter (± 503) 1.06
batch_points_arrow/generate_messages 5047 ns/iter (± 23) 5210 ns/iter (± 17) 0.97
batch_points_arrow/encode_log_msg 261014 ns/iter (± 1870) 259841 ns/iter (± 852) 1.00
batch_points_arrow/encode_total 484626 ns/iter (± 2623) 483714 ns/iter (± 1722) 1.00
batch_points_arrow/decode_log_msg 210395 ns/iter (± 578) 211450 ns/iter (± 914) 1.00
batch_points_arrow/decode_message_bundles 1882 ns/iter (± 6) 1903 ns/iter (± 8) 0.99
batch_points_arrow/decode_total 220476 ns/iter (± 1967) 219484 ns/iter (± 638) 1.00
arrow_mono_points/insert 2290773167 ns/iter (± 6874465) 2318550289 ns/iter (± 8821190) 0.99
arrow_mono_points/query 1173849 ns/iter (± 6443) 1205785 ns/iter (± 8743) 0.97
arrow_batch_points/insert 1149367 ns/iter (± 2168) 1153646 ns/iter (± 3141) 1.00
arrow_batch_points/query 14417 ns/iter (± 36) 14318 ns/iter (± 46) 1.01
arrow_batch_vecs/insert 26492 ns/iter (± 45) 26389 ns/iter (± 76) 1.00
arrow_batch_vecs/query 325760 ns/iter (± 730) 325304 ns/iter (± 981) 1.00
tuid/Tuid::random 34 ns/iter (± 0) 34 ns/iter (± 0) 1

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

Please sign in to comment.