Repository navigation
Camera tracking: skip unused SVD output work in null-vector queries - #2345
Conversation
Share the unchanged Jacobi factors between full SVD and null-vector callers. Select the same right singular vector directly instead of normalizing U and sorting copies that the caller discards. Fixes storytold#2329
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Shared factors and consumers crates/track/src/camtrack/linalg.rs |
svd and null_vector use the shared Jacobi factorization. null_vector selects the smallest singular value and uses the highest index for ties. Tests compare its output bit-for-bit with the last right-singular-vector column from svd across matrix shapes, scales, and an identity-matrix tie case. |
Priority:
Estimated code review effort: 2 (Simple) | ~15 minutes
Change: Refactor
Suggested reviewers: echelon
Merge Risk: 
Minimal · up to 8dbb0
-
No actionable merge-blocking risk is established; the change is mergeable after normal checks.
Architecture risk: 
Medium · up to 8dbb0
-
The change affects 1 system.
Changed systems:
cratesArchitecture concerns
No architecture-level concerns identified.Review details
-
Systems and components
- observed — crates (service) was modified; 1 changed file maps to changed impact.
Before / after behavior
- observed — Modified behavior in crates/track/src/camtrack/linalg.rs:
svdnow callsjacobi_factorsfor unsorted factors, then performs its existing normalization and descending sort. A private shared helper is introduced for the Jacobi factorization. - observed — Modified behavior in crates/track/src/camtrack/linalg.rs:
jacobi_factorsreturns the rotated columns and their norms without normalizing or sorting them; those steps now occur insvd. - observed — Modified behavior in crates/track/src/camtrack/linalg.rs:
null_vectornow selects the smallest singular value directly from the shared raw factors, breaking equal-value ties in favor of the highest index, instead of taking the final column of sortedsvdoutput. - observed — Modified behavior in crates/track/src/camtrack/linalg.rs: Adds a test comparing
null_vectorbit-for-bit with the last right-singular-vector column fromsvdacross empty, rectangular, and square shapes and scales from zero to1e100, plus an identity-matrix tie case.
Reliability and maintainability
- inferred — Risk-relevant change factors for crates: blast_radius_4; direct_dependents_2
-
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Linked Issues check
-
Explanation
The changes satisfy the coding objectives in
#2329.jacobi_factorspreserves the existing Jacobi sweep body and stopping criterion.null_vectoruses the raw factors, selects the smallest singular-value column, and avoids U normalization and sorted copies.svdretains normalization and descending ordering. The added test checks bitwise null-vector equivalence across shapes, scales, zero input, and ties. The PR also reports the requested singular-vector, essential-matrix, Sampson-error, inlier-mask, and reconstruction comparisons.
Full details: Out of Scope Changes check
-
Explanation
The diff changes only
crates/track/src/camtrack/linalg.rs. The refactoring,null_vectorimplementation, and equivalence test directly support#2329. No unrelated production behavior or public API change is shown.
-
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Usage-based review receipt
- Mode: Continue automatically
- Reviewed files: 1
- Waived: $0.25 (charged $0.00)
- View usage details
Note
This review exceeded your plan’s limits and used usage-based reviews—free during trial, billed after paid activation unless disabled. Manage usage-based reviews.
Comment @coderabbitai help to get the list of available commands.
|
This PR is one of 17 from a speed audit of
Notes:
|
|
Merged, thank you @vangel76! It landed on |
Summary
null_vectorused the full SVD output even though it only needs one right singular vector. Share the existing Jacobi factorization core withsvd, then select the required column directly for null-space queries. This avoids normalizing U and allocating sorted U/V copies on that path.Jacobi sweep order, arithmetic and stopping criterion are unchanged. Equal singular values select the same column as the original stable descending sort. Full
svdoutput keeps its previous normalization and ordering.Fixes #2329
Measurements
Release builds based on upstream/main
99190488, Ryzen 7 7800X3D.RAYON_NUM_THREADS=1, core 12,perf stat -e instructions:u,cycles:u; five alternating original/changed pairs, medians. Each process performs 500 RANSAC calls on 500 correspondences, with 10% outliers, small observation noise and up to 400 iterations per call.0.96% fewer instructions: a small measured gain from removing unnecessary output work. The benchmark's aggregate inlier count is identical in all ten runs. These are RANSAC-kernel measurements; counters include setup/input generation. No speedup for the full camera tracker is claimed.
Verification
cargo fmt --all --checkcargo clippy -p effectcraft-track --lib --tests -- -D warningsRAYON_NUM_THREADS=1 cargo test --release -p effectcraft-tracknull_vectorand the full SVD's last V column for square/tall/wide/empty inputs, zero/rank-deficient matrices, scales from 1e-100 to 1e100 and tied singular values.to_bits()across matrix shapes. RANSAC essential matrices, every Sampson error and all inlier masks match bitwise for noisy 3D, planar and near-degenerate scenes (three seeds each).7cd84d48f874c076in all six runs.Overlap
Only
camtrack/linalg.rschanges, around SVD/null-space queries and their test. The Jacobi sweep body andumeyamaare byte-for-byte unchanged; #1876'sumeyamawork is separate. #2342 also editslinalg.rsin the Cholesky function; this branch starts independently from fresh upstream/main. No other agents' files change.Generated with Codex
Summary by CodeRabbit