-
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.
* Refactor: clean up Session slightly * Simplify the API of RerunArgs * CI: run `cargo check -p rerun --no-default-features --features sdk` * Fix errors and warnings when using only the `sdk` feature of rerun * Make LogSink: Sync * Refactor: clean up the contents of Session * Move the tokio runtime out of Session * Clean up Session a bit * Refactor sink names and modules * Clone Session as PythonSession The Python API have different needs from the Rust API * justfile: make sure our just-scripts use `set -euo pipefail` * Add just rs-lint * lint.py: white-list "./web_viewer/re_viewer_debug.js" * Run `typos` in `just lint` * Simplify `Session`, and add `SessionBuilder` * Use --deny-warnings instead of setting RUSTFLAGS less re-compiling * rust.yml: replace `-D` with more explicit `--deny` * Make ahash a workspace dependency * Remove typos from just py-lint again since it runs on CI * Make Session: Clone * Make sure `Session` is `Send` and `Sync` * Make `tracing` and `tracing-subscriber` workspace dependencies * Less `mut Session` * Remove lint of `dbg!` (clippy checks it now) * MsgSender::send can be used with both Session and LogSink * bug fix * Cleanup * Add Session::sink to access the underlying sink * Document the built-in log level names * Simplify TCP client by removing the `set_addr` method * Update TcpClient documentation * Use thiserror to report LogMsg encoding errors * Replace some more `anyhow` with `thiserror` * fix copy-paste bug Co-authored-by: Jeremy Leibs <[email protected]> * fix copy-paste bug Co-authored-by: Jeremy Leibs <[email protected]> * Sleep longer * Simplify code with SessionBuilder::buffered --------- Co-authored-by: Jeremy Leibs <[email protected]>
- Loading branch information
Showing
49 changed files
with
998 additions
and
600 deletions.
There are no files selected for viewing
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
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
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,80 @@ | ||
use std::{path::PathBuf, sync::mpsc::Sender}; | ||
|
||
use parking_lot::Mutex; | ||
|
||
use re_log_types::LogMsg; | ||
|
||
/// Errors that can occur when creating a [`FileSink`]. | ||
#[derive(thiserror::Error, Debug)] | ||
pub enum FileSinkError { | ||
/// Error creating the file. | ||
#[error("Failed to create file {0}: {1}")] | ||
CreateFile(PathBuf, std::io::Error), | ||
|
||
/// Error spawning the file writer thread. | ||
#[error("Failed to spawn thread: {0}")] | ||
SpawnThread(std::io::Error), | ||
|
||
/// Error encoding a log message. | ||
#[error("Failed to encode LogMsg: {0}")] | ||
LogMsgEncode(#[from] re_log_types::encoding::EncodeError), | ||
} | ||
|
||
/// Stream log messages to an `.rrd` file. | ||
pub struct FileSink { | ||
// None = quit | ||
tx: Mutex<Sender<Option<LogMsg>>>, | ||
join_handle: Option<std::thread::JoinHandle<()>>, | ||
} | ||
|
||
impl Drop for FileSink { | ||
fn drop(&mut self) { | ||
self.tx.lock().send(None).ok(); | ||
if let Some(join_handle) = self.join_handle.take() { | ||
join_handle.join().ok(); | ||
} | ||
} | ||
} | ||
|
||
impl FileSink { | ||
/// Start writing log messages to a file at the given path. | ||
pub fn new(path: impl Into<std::path::PathBuf>) -> Result<Self, FileSinkError> { | ||
let (tx, rx) = std::sync::mpsc::channel(); | ||
|
||
let path = path.into(); | ||
|
||
re_log::debug!("Saving file to {path:?}…"); | ||
|
||
let file = std::fs::File::create(&path) | ||
.map_err(|err| FileSinkError::CreateFile(path.clone(), err))?; | ||
let mut encoder = re_log_types::encoding::Encoder::new(file)?; | ||
|
||
let join_handle = std::thread::Builder::new() | ||
.name("file_writer".into()) | ||
.spawn(move || { | ||
while let Ok(Some(log_msg)) = rx.recv() { | ||
if let Err(err) = encoder.append(&log_msg) { | ||
re_log::error!("Failed to save log stream to {path:?}: {err}"); | ||
return; | ||
} | ||
} | ||
if let Err(err) = encoder.finish() { | ||
re_log::error!("Failed to save log stream to {path:?}: {err}"); | ||
} else { | ||
re_log::debug!("Log stream saved to {path:?}"); | ||
} | ||
}) | ||
.map_err(FileSinkError::SpawnThread)?; | ||
|
||
Ok(Self { | ||
tx: tx.into(), | ||
join_handle: Some(join_handle), | ||
}) | ||
} | ||
} | ||
|
||
impl crate::sink::LogSink for FileSink { | ||
fn send(&self, msg: LogMsg) { | ||
self.tx.lock().send(Some(msg)).ok(); | ||
} | ||
} |
Oops, something went wrong.
93edfca
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rust Benchmark
datastore/insert/batch/rects/insert
557404
ns/iter (± 1931
)548497
ns/iter (± 2367
)1.02
datastore/latest_at/batch/rects/query
1821
ns/iter (± 8
)1813
ns/iter (± 19
)1.00
datastore/latest_at/missing_components/primary
356
ns/iter (± 1
)358
ns/iter (± 0
)0.99
datastore/latest_at/missing_components/secondaries
424
ns/iter (± 1
)428
ns/iter (± 1
)0.99
datastore/range/batch/rects/query
152292
ns/iter (± 498
)154861
ns/iter (± 1385
)0.98
mono_points_arrow/generate_message_bundles
52935324
ns/iter (± 946607
)47672724
ns/iter (± 865707
)1.11
mono_points_arrow/generate_messages
140038594
ns/iter (± 1121718
)124757765
ns/iter (± 1181023
)1.12
mono_points_arrow/encode_log_msg
165644765
ns/iter (± 1298114
)153929398
ns/iter (± 963943
)1.08
mono_points_arrow/encode_total
362959572
ns/iter (± 1770620
)326350073
ns/iter (± 1562282
)1.11
mono_points_arrow/decode_log_msg
188895962
ns/iter (± 1148497
)176527715
ns/iter (± 826705
)1.07
mono_points_arrow/decode_message_bundles
75769133
ns/iter (± 2391124
)64587172
ns/iter (± 803674
)1.17
mono_points_arrow/decode_total
262326604
ns/iter (± 1900899
)239435670
ns/iter (± 1442385
)1.10
batch_points_arrow/generate_message_bundles
333138
ns/iter (± 1004
)321217
ns/iter (± 2360
)1.04
batch_points_arrow/generate_messages
6392
ns/iter (± 21
)6074
ns/iter (± 38
)1.05
batch_points_arrow/encode_log_msg
375721
ns/iter (± 1652
)367448
ns/iter (± 1512
)1.02
batch_points_arrow/encode_total
729575
ns/iter (± 2652
)713399
ns/iter (± 3010
)1.02
batch_points_arrow/decode_log_msg
353623
ns/iter (± 928
)345738
ns/iter (± 1971
)1.02
batch_points_arrow/decode_message_bundles
2099
ns/iter (± 16
)2087
ns/iter (± 13
)1.01
batch_points_arrow/decode_total
357774
ns/iter (± 3224
)353766
ns/iter (± 940
)1.01
arrow_mono_points/insert
7259721552
ns/iter (± 149385179
)6018780763
ns/iter (± 22048901
)1.21
arrow_mono_points/query
1743373
ns/iter (± 36429
)1707188
ns/iter (± 9562
)1.02
arrow_batch_points/insert
2772973
ns/iter (± 78195
)2685137
ns/iter (± 18624
)1.03
arrow_batch_points/query
16888
ns/iter (± 47
)16849
ns/iter (± 93
)1.00
arrow_batch_vecs/insert
41866
ns/iter (± 141
)41667
ns/iter (± 1063
)1.00
arrow_batch_vecs/query
389761
ns/iter (± 1875
)388567
ns/iter (± 1289
)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.