Skip to content

Commit 14590be

Browse files
authored
Always-on AV1 in --release; opt-in to nasm-optimizations (#7661)
### What Even without `nasm`, it is pretty fast. I also added a warning to the user that they can get more performance by enabling the `nasm` feature. ### Checklist * [x] I have read and agree to [Contributor Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md) * [x] I've included a screenshot or gif (if applicable) * [x] I have tested the web demo (if applicable): * Using examples from latest `main` build: [rerun.io/viewer](https://rerun.io/viewer/pr/7661?manifest_url=https://app.rerun.io/version/main/examples_manifest.json) * Using full set of examples from `nightly` build: [rerun.io/viewer](https://rerun.io/viewer/pr/7661?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json) * [x] The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG * [x] If applicable, add a new check to the [release checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)! * [x] If have noted any breaking changes to the log API in `CHANGELOG.md` and the migration guide - [PR Build Summary](https://build.rerun.io/pr/7661) - [Recent benchmark results](https://build.rerun.io/graphs/crates.html) - [Wasm size tracking](https://build.rerun.io/graphs/sizes.html) To run all checks from `main`, comment on the PR with `@rerun-bot full-check`.
1 parent a2705b7 commit 14590be

File tree

11 files changed

+46
-36
lines changed

11 files changed

+46
-36
lines changed

Cargo.lock

+1
Original file line numberDiff line numberDiff line change
@@ -6234,6 +6234,7 @@ dependencies = [
62346234
"re_smart_channel",
62356235
"re_tracing",
62366236
"re_types",
6237+
"re_video",
62376238
"re_viewer",
62386239
"re_web_viewer_server",
62396240
"re_ws_comms",

crates/store/re_video/Cargo.toml

+6-3
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,15 @@ no-default-features = true
2424
features = ["all"]
2525

2626
[features]
27-
default = []
27+
default = ["av1"]
2828

29-
## Opt-in to native AV1 decoding.
30-
## You need to install [nasm](https://nasm.us/) to compile with this feature.
29+
## Native AV1 decoding.
3130
av1 = ["dep:dav1d"]
3231

32+
## Enable faster native video decoding with assembly.
33+
## You need to install [nasm](https://nasm.us/) to compile with this feature.
34+
nasm = ["dav1d?/default"] # The default feature set of dav1d has asm enabled
35+
3336
[dependencies]
3437
re_log.workspace = true
3538
re_tracing.workspace = true

crates/store/re_video/src/decode/av1.rs

+8
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ impl SyncDav1dDecoder {
1616
pub fn new() -> Result<Self> {
1717
re_tracing::profile_function!();
1818

19+
if !cfg!(feature = "nasm") {
20+
re_log::warn_once!(
21+
"NOTE: native AV1 video decoder is running extra slowly. \
22+
Speed it up by compiling Rerun with the `nasm` feature enabled. \
23+
You'll need to also install nasm: https://nasm.us/"
24+
);
25+
}
26+
1927
// See https://videolan.videolan.me/dav1d/structDav1dSettings.html for settings docs
2028
let mut settings = dav1d::Settings::new();
2129

crates/top/rerun-cli/Cargo.toml

+6-4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ repository.workspace = true
2020
rust-version.workspace = true
2121
version.workspace = true
2222

23+
default-run = "rerun" # If someone types `cargo run` in this workspace, this is what we staert
24+
2325
[lints]
2426
workspace = true
2527

@@ -39,14 +41,14 @@ doc = false
3941
# so wer have all the bells and wistles here
4042
default = ["native_viewer", "web_viewer"]
4143

44+
## Enable faster native video decoding with assembly.
45+
## You need to install [nasm](https://nasm.us/) to compile with this feature.
46+
nasm = ["rerun/nasm"]
47+
4248
## Support spawning a native viewer.
4349
## This adds a lot of extra dependencies, so only enable this feature if you need it!
4450
native_viewer = ["rerun/native_viewer"]
4551

46-
## Support for native AV1 video decoding.
47-
## You need to install [nasm](https://nasm.us/) to compile with this feature.
48-
video_av1 = ["rerun/video_av1"]
49-
5052
## Support serving a web viewer over HTTP.
5153
##
5254
## Enabling this inflates the binary size quite a bit, since it embeds the viewer wasm.

crates/top/rerun/Cargo.toml

+10-4
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ ecolor = ["re_types?/ecolor"]
7171
## Integration with the [`log`](https://crates.io/crates/log/) crate.
7272
log = ["dep:env_logger", "dep:log"]
7373

74+
## Enable faster native video decoding with assembly.
75+
## You need to install [nasm](https://nasm.us/) to compile with this feature.
76+
nasm = ["re_video/nasm"]
77+
7478
## Support spawning a native viewer.
7579
## This adds a lot of extra dependencies, so only enable this feature if you need it!
7680
native_viewer = ["dep:re_viewer"]
@@ -94,10 +98,6 @@ server = ["re_sdk_comms?/server"]
9498
## Embed the Rerun SDK & built-in types and re-export all of their public symbols.
9599
sdk = ["dep:re_sdk", "dep:re_types"]
96100

97-
## Support for native AV1 video decoding.
98-
## You need to install [nasm](https://nasm.us/) to compile with this feature.
99-
video_av1 = ["re_viewer?/video_av1"]
100-
101101
## Support serving a web viewer over HTTP.
102102
##
103103
## Enabling this inflates the binary size quite a bit, since it embeds the viewer wasm.
@@ -117,10 +117,12 @@ re_entity_db.workspace = true
117117
re_error.workspace = true
118118
re_format.workspace = true
119119
re_log_types.workspace = true
120+
re_video.workspace = true
120121
re_log.workspace = true
121122
re_memory.workspace = true
122123
re_smart_channel.workspace = true
123124
re_tracing.workspace = true
125+
124126
anyhow.workspace = true
125127
document-features.workspace = true
126128
itertools.workspace = true
@@ -155,3 +157,7 @@ unindent = { workspace = true, optional = true }
155157

156158
[build-dependencies]
157159
re_build_tools.workspace = true
160+
161+
[package.metadata.cargo-machete]
162+
# We only depend on re_video so we can enable extra features for it
163+
ignored = ["re_video"]

crates/viewer/re_renderer/Cargo.toml

+1-5
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ default = ["import-obj", "import-gltf", "import-stl"]
3535
## Support for Arrow datatypes for end-to-end zero-copy.
3636
arrow = ["dep:arrow2"]
3737

38-
## Support for native AV1 video decoding.
39-
## You need to install [nasm](https://nasm.us/) to compile with this feature.
40-
video_av1 = ["re_video/av1"]
41-
4238
## Support importing .obj files
4339
import-obj = ["dep:tobj"]
4440

@@ -56,7 +52,7 @@ re_error.workspace = true
5652
re_log.workspace = true
5753
re_math.workspace = true
5854
re_tracing.workspace = true
59-
re_video.workspace = true
55+
re_video = { workspace = true, default-features = true }
6056

6157
ahash.workspace = true
6258
anyhow.workspace = true

crates/viewer/re_renderer/src/video/decoder/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -127,24 +127,24 @@ impl VideoDecoder {
127127
if #[cfg(target_arch = "wasm32")] {
128128
let decoder = web::WebVideoDecoder::new(data.clone(), hw_acceleration)?;
129129
return Ok(Self::from_chunk_decoder(render_ctx, data, decoder));
130-
} else if #[cfg(feature = "video_av1")] {
130+
} else {
131+
// Native AV1 video decoding:
132+
131133
if !data.config.is_av1() {
132134
return Err(DecodingError::UnsupportedCodec {
133135
codec: data.human_readable_codec_string(),
134136
});
135137
}
136138

137139
if cfg!(debug_assertions) {
138-
return Err(DecodingError::NoNativeDebug); // because debug builds of rav1d are so slow
140+
return Err(DecodingError::NoNativeDebug); // because debug builds of rav1d are EXTREMELY slow
139141
} else {
140142
let av1_decoder = re_video::decode::av1::SyncDav1dDecoder::new()
141143
.map_err(|err| DecodingError::StartDecoder(err.to_string()))?;
142144

143145
let decoder = native_decoder::NativeDecoder::new(debug_name, Box::new(av1_decoder))?;
144146
return Ok(Self::from_chunk_decoder(render_ctx, data, decoder));
145147
};
146-
} else {
147-
return Err(DecodingError::NoNativeSupport);
148148
}
149149
}
150150
}

crates/viewer/re_renderer/src/video/mod.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,11 @@ pub enum DecodingError {
5454
BadData,
5555

5656
#[cfg(not(target_arch = "wasm32"))]
57-
#[error("No native video support. Try compiling rerun with the `video_av1` feature flag")]
58-
NoNativeSupport,
59-
60-
#[cfg(not(target_arch = "wasm32"))]
61-
#[cfg(feature = "video_av1")]
6257
#[error("Unsupported codec: {codec:?}. Only AV1 is currently supported on native.")]
6358
UnsupportedCodec { codec: String },
6459

6560
#[cfg(not(target_arch = "wasm32"))]
66-
#[cfg(feature = "video_av1")]
67-
#[error("Video decoding not supported in native debug builds.")]
61+
#[error("Native video decoding not supported in native debug builds.")]
6862
NoNativeDebug,
6963
}
7064

crates/viewer/re_viewer/Cargo.toml

-4
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ default = ["analytics"]
3636
## Enable telemetry using our analytics SDK.
3737
analytics = ["dep:re_analytics"]
3838

39-
## Support for native AV1 video decoding.
40-
## You need to install [nasm](https://nasm.us/) to compile with this feature.
41-
video_av1 = ["re_renderer/video_av1"]
42-
4339

4440
[dependencies]
4541
# Internal:

pixi.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -122,18 +122,18 @@ man = "cargo --quiet run --package rerun-cli --all-features -- man > docs/conten
122122
# Compile and run the rerun viewer.
123123
#
124124
# You can also give an argument for what to view (e.g. an .rrd file).
125-
rerun = "cargo run --package rerun-cli --no-default-features --features native_viewer,video_av1 --"
125+
rerun = "cargo run --package rerun-cli --no-default-features --features native_viewer,nasm --"
126126

127127
# Compile `rerun-cli` without the web-viewer.
128-
rerun-build = "cargo build --package rerun-cli --no-default-features --features native_viewer,video_av1"
128+
rerun-build = "cargo build --package rerun-cli --no-default-features --features native_viewer,nasm"
129129

130130
# Compile `rerun-cli` without the web-viewer.
131-
rerun-build-release = "cargo build --package rerun-cli --release --no-default-features --features native_viewer,video_av1"
131+
rerun-build-release = "cargo build --package rerun-cli --release --no-default-features --features native_viewer,nasm"
132132

133133
# Compile and run the rerun viewer with --release.
134134
#
135135
# You can also give an argument for what to view (e.g. an .rrd file).
136-
rerun-release = "cargo run --package rerun-cli --no-default-features --features native_viewer,video_av1 --release --"
136+
rerun-release = "cargo run --package rerun-cli --no-default-features --features native_viewer,nasm --release --"
137137

138138
# Compile and run the web-viewer via rerun-cli.
139139
#

rerun_py/Cargo.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ default = ["extension-module"]
1919

2020
## The features we turn on when building the `rerun-sdk` PyPi package
2121
## for <https://pypi.org/project/rerun-sdk/>.
22-
pypi = ["extension-module", "web_viewer"]
22+
pypi = ["extension-module", "nasm", "web_viewer"]
2323

2424
## We need to enable the `pyo3/extension-module` when building the SDK,
2525
## but we cannot enable it when building tests and benchmarks, so we
@@ -28,6 +28,10 @@ pypi = ["extension-module", "web_viewer"]
2828
## * <https://pyo3.rs/main/building-and-distribution#building-python-extension-modules>
2929
extension-module = ["pyo3/extension-module"]
3030

31+
## Enable faster native video decoding with assembly.
32+
## You need to install [nasm](https://nasm.us/) to compile with this feature.
33+
nasm = ["re_video/nasm"]
34+
3135
## Support serving a web viewer over HTTP with `serve()`.
3236
##
3337
## Enabling this adds quite a bit to the binary size,

0 commit comments

Comments
 (0)