Commit 30a99c6
committed
perf(patchworkpp): kill per-patch heap traffic in R-VPF / R-GPF (+14.8% Hz)
Three changes inside PatchWorkpp::extract_piecewiseground and
PatchWorkpp::estimate_plane that together take KITTI seq 00 from
97.5 Hz to 111.9 Hz (median, 24-core i7-12700, 2900 timed frames):
* estimate_plane: replace MatrixX3f eigen_ground / centered /
centered.adjoint() * centered with a single-pass scalar accumulation
of mean and 9 cross-products, then build the 3x3 cov on the stack.
No more per-call Eigen heap allocations.
* extract_piecewiseground: promote src_wo_verticals and src_tmp to
reused instance scratch members. Per-patch malloc pressure on the
glibc heap (which was serialising the loop, see issue #96) goes away
after the first few patches because vector::clear() retains capacity.
* estimateGround main loop: `auto& zone` instead of `auto zone` for the
ConcentricZoneModel_[zone_idx] read. Avoids a deep-copy of the full
3-level nested vector per outer iteration; the in-place std::sort is
safe because each (zone, ring, sector) patch is read once and the
CZM is flushed at the top of every estimateGround call.
Also (smaller wins, kept for cleanliness):
* JacobiSVD<Matrix3f> -> SelfAdjointEigenSolver::computeDirect on the
3x3 PSD covariance in both cpp/common/src/plane_fit.cpp and the
patchworkpp in-place estimate_plane. Closed-form, no Jacobi iterations.
singular_values_ is repacked descending so every consumer (linearity_
/ planarity_ in common, flatness_thr index (2) in patchwork classic,
ground_flatness=minCoeff() and line_variable=sv(0)/sv(1) in
patchwork++) keeps the same convention bit-for-bit.
* const& on addCloud's 'add' parameter, RevertCandidate loop variables,
and the temporal_ground_revert / calc_point_to_plane_d /
calc_mean_stdev signatures.
Numerical equivalence verified end-to-end on KITTI seq 00:
* patchwork (pw protocol): P/R/F1 unchanged to 0.01 (bit-identical).
* patchwork++ (pp protocol): F1 96.62 -> 96.63 (delta 0.01, well within
the ±0.05 macro budget). Algebraic identity of JacobiSVD vs eigh on
500 real KITTI patch covariances confirmed to FP precision for all
derived scalars (linearity_, planarity_, ground_flatness,
line_variable, normal_ up to sign).
Patchwork classic is unchanged on the perf side (TBB-bound, SVD is
sub-µs/patch after parallel_for); the win is concentrated in
Patchwork++ where these allocations dominated the profile.1 parent cb8e449 commit 30a99c6
3 files changed
Lines changed: 104 additions & 56 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
24 | 34 | | |
25 | 35 | | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
32 | 42 | | |
33 | 43 | | |
34 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
198 | 205 | | |
199 | 206 | | |
200 | 207 | | |
201 | 208 | | |
202 | 209 | | |
203 | 210 | | |
204 | 211 | | |
205 | | - | |
| 212 | + | |
206 | 213 | | |
207 | 214 | | |
208 | 215 | | |
209 | 216 | | |
210 | 217 | | |
211 | 218 | | |
212 | 219 | | |
213 | | - | |
214 | | - | |
| 220 | + | |
| 221 | + | |
215 | 222 | | |
216 | 223 | | |
217 | | - | |
218 | | - | |
| 224 | + | |
| 225 | + | |
219 | 226 | | |
220 | 227 | | |
221 | 228 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
56 | 71 | | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
77 | 103 | | |
78 | 104 | | |
79 | | - | |
| 105 | + | |
80 | 106 | | |
81 | 107 | | |
82 | 108 | | |
| |||
201 | 227 | | |
202 | 228 | | |
203 | 229 | | |
204 | | - | |
| 230 | + | |
205 | 231 | | |
206 | 232 | | |
207 | 233 | | |
| |||
275 | 301 | | |
276 | 302 | | |
277 | 303 | | |
278 | | - | |
| 304 | + | |
279 | 305 | | |
280 | 306 | | |
281 | 307 | | |
| |||
391 | 417 | | |
392 | 418 | | |
393 | 419 | | |
394 | | - | |
395 | | - | |
| 420 | + | |
| 421 | + | |
396 | 422 | | |
397 | 423 | | |
398 | 424 | | |
| |||
408 | 434 | | |
409 | 435 | | |
410 | 436 | | |
411 | | - | |
| 437 | + | |
412 | 438 | | |
413 | 439 | | |
414 | 440 | | |
| |||
470 | 496 | | |
471 | 497 | | |
472 | 498 | | |
473 | | - | |
474 | | - | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
475 | 504 | | |
476 | 505 | | |
477 | 506 | | |
478 | | - | |
| 507 | + | |
479 | 508 | | |
480 | 509 | | |
481 | 510 | | |
482 | | - | |
483 | | - | |
484 | | - | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
485 | 514 | | |
486 | | - | |
| 515 | + | |
487 | 516 | | |
488 | 517 | | |
489 | 518 | | |
490 | 519 | | |
491 | 520 | | |
492 | | - | |
| 521 | + | |
493 | 522 | | |
494 | 523 | | |
495 | 524 | | |
| |||
500 | 529 | | |
501 | 530 | | |
502 | 531 | | |
503 | | - | |
| 532 | + | |
504 | 533 | | |
505 | 534 | | |
506 | 535 | | |
507 | 536 | | |
508 | 537 | | |
509 | | - | |
| 538 | + | |
510 | 539 | | |
511 | 540 | | |
512 | 541 | | |
| |||
538 | 567 | | |
539 | 568 | | |
540 | 569 | | |
541 | | - | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
542 | 573 | | |
543 | 574 | | |
544 | 575 | | |
545 | | - | |
| 576 | + | |
546 | 577 | | |
547 | 578 | | |
548 | 579 | | |
| |||
0 commit comments