Skip to content

Commit

Permalink
Remove extreneous image features and dependencies (#1425)
Browse files Browse the repository at this point in the history
* Cut out all image dependencies except for png and jpeg

* Small refactor of re_log: split out a file

* deny.toml: remove recursive exceptions for `ring` and `winit`

* ci: cargo deny check all four target platforms

* fix cargo deny CI snafu

* Still I messed up the CI command
  • Loading branch information
emilk authored Feb 28, 2023
1 parent 9dd0721 commit a6ae6cd
Show file tree
Hide file tree
Showing 13 changed files with 98 additions and 189 deletions.
22 changes: 20 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,26 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: cargo deny
- name: cargo deny aarch64-apple-darwin check
uses: actions-rs/cargo@v1
with:
command: deny
args: --log-level=error check
args: --log-level=error --all-features --target aarch64-apple-darwin check

- name: cargo deny wasm32-unknown-unknown check
uses: actions-rs/cargo@v1
with:
command: deny
args: --log-level=error --all-features --target wasm32-unknown-unknown check

- name: cargo deny x86_64-pc-windows-msvc
uses: actions-rs/cargo@v1
with:
command: deny
args: --log-level=error --all-features --target x86_64-pc-windows-msvc check

- name: cargo deny x86_64-unknown-linux-musl check
uses: actions-rs/cargo@v1
with:
command: deny
args: --log-level=error --all-features --target x86_64-unknown-linux-musl check
123 changes: 4 additions & 119 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ epaint = "0.21.0"
glam = "0.22"
gltf = "1.1"
half = "2.0"
image = "0.24"
image = { version = "0.24", default-features = false }
lazy_static = "1.4"
macaw = "0.18"
mimalloc = "0.1.29"
Expand Down
56 changes: 2 additions & 54 deletions crates/re_log/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,58 +16,6 @@ pub use tracing::{debug, error, info, trace, warn};
// similar to how the log console in a browser will automatically suppress duplicates.
pub use log_once::{debug_once, error_once, info_once, trace_once, warn_once};

/// Set `RUST_LOG` environment variable to `info`, unless set,
/// and also set some other log levels on crates that are too loud.
#[cfg(not(target_arch = "wasm32"))]
fn set_default_rust_log_env() {
let mut rust_log = std::env::var("RUST_LOG").unwrap_or_else(|_| "info".to_owned());
mod setup;

const LOUD_CRATES: [&str; 7] = [
// wgpu crates spam a lot on info level, which is really annoying
// TODO(emilk): remove once https://github.com/gfx-rs/wgpu/issues/3206 is fixed
"naga",
"wgpu_core",
"wgpu_hal",
// These are quite spammy on debug, drowning out what we care about:
"h2",
"hyper",
"rustls",
"ureq",
];
for loud_crate in LOUD_CRATES {
if !rust_log.contains(&format!("{loud_crate}=")) {
rust_log += &format!(",{loud_crate}=warn");
}
}

std::env::set_var("RUST_LOG", rust_log);

if std::env::var("RUST_BACKTRACE").is_err() {
// Make sure we always produce backtraces for the (hopefully rare) cases when we crash!
std::env::set_var("RUST_BACKTRACE", "1");
}
}

#[cfg(not(target_arch = "wasm32"))]
pub fn setup_native_logging() {
set_default_rust_log_env();
tracing_subscriber::fmt::init(); // log to stdout
}

#[cfg(target_arch = "wasm32")]
fn default_web_log_filter() -> String {
"debug,naga=warn,wgpu_core=warn,wgpu_hal=warn".to_owned()
}

#[cfg(target_arch = "wasm32")]
pub fn setup_web_logging() {
use tracing_subscriber::layer::SubscriberExt as _;
tracing::subscriber::set_global_default(
tracing_subscriber::Registry::default()
.with(tracing_subscriber::EnvFilter::new(default_web_log_filter()))
.with(tracing_wasm::WASMLayer::new(
tracing_wasm::WASMLayerConfig::default(),
)),
)
.expect("Failed to set tracing subscriber.");
}
pub use setup::*;
57 changes: 57 additions & 0 deletions crates/re_log/src/setup.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//! Function to setup logging in binaries and web apps.
/// Set `RUST_LOG` environment variable to `info`, unless set,
/// and also set some other log levels on crates that are too loud.
#[cfg(not(target_arch = "wasm32"))]
fn set_default_rust_log_env() {
let mut rust_log = std::env::var("RUST_LOG").unwrap_or_else(|_| "info".to_owned());

const LOUD_CRATES: [&str; 7] = [
// wgpu crates spam a lot on info level, which is really annoying
// TODO(emilk): remove once https://github.com/gfx-rs/wgpu/issues/3206 is fixed
"naga",
"wgpu_core",
"wgpu_hal",
// These are quite spammy on debug, drowning out what we care about:
"h2",
"hyper",
"rustls",
"ureq",
];
for loud_crate in LOUD_CRATES {
if !rust_log.contains(&format!("{loud_crate}=")) {
rust_log += &format!(",{loud_crate}=warn");
}
}

std::env::set_var("RUST_LOG", rust_log);

if std::env::var("RUST_BACKTRACE").is_err() {
// Make sure we always produce backtraces for the (hopefully rare) cases when we crash!
std::env::set_var("RUST_BACKTRACE", "1");
}
}

#[cfg(not(target_arch = "wasm32"))]
pub fn setup_native_logging() {
set_default_rust_log_env();
tracing_subscriber::fmt::init(); // log to stdout
}

#[cfg(target_arch = "wasm32")]
fn default_web_log_filter() -> String {
"debug,naga=warn,wgpu_core=warn,wgpu_hal=warn".to_owned()
}

#[cfg(target_arch = "wasm32")]
pub fn setup_web_logging() {
use tracing_subscriber::layer::SubscriberExt as _;
tracing::subscriber::set_global_default(
tracing_subscriber::Registry::default()
.with(tracing_subscriber::EnvFilter::new(default_web_log_filter()))
.with(tracing_wasm::WASMLayer::new(
tracing_wasm::WASMLayerConfig::default(),
)),
)
.expect("Failed to set tracing subscriber.");
}
1 change: 1 addition & 0 deletions crates/re_log_types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ ecolor = { workspace = true, optional = true }
glam = { workspace = true, optional = true }
image = { workspace = true, optional = true, default-features = false, features = [
"jpeg",
# "jpeg_rayon", # TODO(emilk): when https://github.com/rayon-rs/rayon/pull/1019 is released
] }
macaw = { workspace = true, optional = true }
rand = { version = "0.8", optional = true }
Expand Down
Loading

1 comment on commit a6ae6cd

@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: a6ae6cd Previous: 9dd0721 Ratio
datastore/insert/batch/rects/insert 565239 ns/iter (± 10240) 552839 ns/iter (± 1555) 1.02
datastore/latest_at/batch/rects/query 1828 ns/iter (± 7) 1858 ns/iter (± 3) 0.98
datastore/latest_at/missing_components/primary 355 ns/iter (± 0) 360 ns/iter (± 0) 0.99
datastore/latest_at/missing_components/secondaries 424 ns/iter (± 1) 441 ns/iter (± 0) 0.96
datastore/range/batch/rects/query 152332 ns/iter (± 250) 153205 ns/iter (± 175) 0.99
mono_points_arrow/generate_message_bundles 51191698 ns/iter (± 955801) 51667143 ns/iter (± 776479) 0.99
mono_points_arrow/generate_messages 136997970 ns/iter (± 2255304) 136529036 ns/iter (± 1368618) 1.00
mono_points_arrow/encode_log_msg 167925911 ns/iter (± 1184384) 164915682 ns/iter (± 1272510) 1.02
mono_points_arrow/encode_total 357179621 ns/iter (± 2266465) 355000661 ns/iter (± 1569681) 1.01
mono_points_arrow/decode_log_msg 188321496 ns/iter (± 1188677) 187507888 ns/iter (± 1253201) 1.00
mono_points_arrow/decode_message_bundles 73647285 ns/iter (± 1285935) 73421272 ns/iter (± 990524) 1.00
mono_points_arrow/decode_total 259513976 ns/iter (± 2540226) 255685610 ns/iter (± 1671829) 1.01
batch_points_arrow/generate_message_bundles 332860 ns/iter (± 762) 331315 ns/iter (± 940) 1.00
batch_points_arrow/generate_messages 6271 ns/iter (± 14) 6235 ns/iter (± 32) 1.01
batch_points_arrow/encode_log_msg 357590 ns/iter (± 3199) 373073 ns/iter (± 1054) 0.96
batch_points_arrow/encode_total 711172 ns/iter (± 3328) 728315 ns/iter (± 1973) 0.98
batch_points_arrow/decode_log_msg 350382 ns/iter (± 1271) 348473 ns/iter (± 2147) 1.01
batch_points_arrow/decode_message_bundles 2127 ns/iter (± 14) 2067 ns/iter (± 13) 1.03
batch_points_arrow/decode_total 356806 ns/iter (± 1498) 353838 ns/iter (± 1559) 1.01
arrow_mono_points/insert 6836053421 ns/iter (± 16533220) 7067218254 ns/iter (± 93773459) 0.97
arrow_mono_points/query 1738813 ns/iter (± 14276) 1757357 ns/iter (± 11032) 0.99
arrow_batch_points/insert 2667543 ns/iter (± 10026) 2700572 ns/iter (± 18266) 0.99
arrow_batch_points/query 17655 ns/iter (± 29) 16816 ns/iter (± 54) 1.05
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.