Repository navigation
perf(scopes): avoid cloning full-frame samples on draw (#81) - #95
Open
liangshengsheng12333 wants to merge 2 commits into
Open
liangshengsheng12333 wants to merge 2 commits into
liangshengsheng12333 wants to merge 2 commits into
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #81.
Previously,
LumaDataSource::luma_samplesandChromaDataSource::chroma_samplesreturned a freshly clonedVecon every read, andScopeStatealso cloned(*scope.luma)/(*scope.chroma)when updating fromScopeData. On high-resolution (e.g., 4K) frames, this added full-frame allocations and copies on the scopes draw path.Changes
crates/oak-app/src/widgets/scopes/mod.rs:LumaDataSource::luma_samples(&self)to return&[f32]andChromaDataSource::chroma_samples(&self)to return&[(f32, f32)].Histogram::bins,Waveform::envelope,Vectorscope::points, and theMockLuma/MockChromatest sources to borrow slices directly without cloning.ptr::eq) against the underlying buffers inscopes_render_from_mock_data.crates/oak-app/src/panels/program_viewer.rs:Arc<Vec<f32>>andArc<Vec<(f32, f32)>>inScopeStateinstead of ownedVecs, and sharescope.luma/scope.chromaArchandles directly on frame updates.&self.luma/&self.chroma) fromScopeState'sLumaDataSourceandChromaDataSourceimplementations so drawing and paused redraws incur zero full-frame copies.crates/oak-app/src/panels/program_viewer/tests.rs:scopes_tab_renders_from_the_current_frameto assertArc::ptr_eqbetweenScopeStateand engineScopeData, slice pointer identity (ptr::eq), and buffer reuse across paused redraws.Testing
rustfmt --edition 2024 --checkon all modified files: passed.python tooling/check_sdk_consumers.py: passed.rustc --edition 2024 --test crates/oak-app/src/widgets/scopes/math.rs: 10/10 unit tests passed.cargo test -p oak-apprelies on CI (local checkout lacks thequercus-enginesubmodule).