Skip to content

feat(codec): deserializePointCloudView — decode PJ.PointCloud without copying the points (0.35.0) - #201

Merged
facontidavide merged 1 commit into
mainfrom
feat/pointcloud-zero-copy
Sep 28, 2026
Merged

facontidavide merged 1 commit into
mainfrom
feat/pointcloud-zero-copy

Conversation

@facontidavide

@facontidavide facontidavide commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • New PJ::deserializePointCloudView(data, size, BufferAnchor anchor) in pj_base/builtin/point_cloud_codec.hpp. It decodes a canonical PJ.PointCloud while pointing data into the input buffer instead of copying it, and keeps that buffer alive through the caller's anchor. This mirrors deserializeVideoFrameView.
  • A null anchor falls back to a copy, so behaviour matches deserializePointCloud(), which is unchanged.
  • Both public functions call a shared internal decodePointCloud, so validation and field handling are the same code path.
  • I used a new name rather than an overload because builtin_object_codec.cpp takes &deserializePointCloud, and an overload would make that ambiguous, for consumers as well.

Why

PJ4's host decodes every point-cloud sample from the ObjectStore, and that payload is already immutable and anchored. Measured on the PJ4 QRhi branch (Iris Xe, 5 interleaved rounds) with a local build of this change:

10M-point stream wall GUI CPU faults/frame
copy (deserializePointCloud) 137 ms 124 ms ~29k
view (deserializePointCloudView) 71 ms 57 ms 1

At 300k points, GUI CPU goes from 1.73 to 1.36 ms.

Versioning

MINOR (0.35.0). This is an additive client-side helper: no host surface, no vtable or ABI change, and existing binaries are unaffected. The CHANGELOG records Host contract: unchanged (no floor impact), and VERSION is bumped.

Test plan

  • point_cloud_codec_test: 7/7 pass, including 3 new tests:
    • the view aliases the anchored bytes;
    • a null anchor copies;
    • the view rejects exactly what the copying decoder rejects.
  • pre-commit (clang-format, whitespace) is clean.
  • PJ4 built against this branch via ./build.sh --sdk-local: the point-cloud golden images are byte-identical.
  • CI

🤖 Generated with Claude Code

https://claude.ai/code/session_01V3ZZU95hWdyWcCj8dQkmAi

… copying the points (0.35.0)

deserializePointCloud() copies the packed point bytes out of the wire buffer
for every sample. deserializePointCloudView(data, size, anchor) points the
cloud's `data` into the input instead and keeps it alive through the caller's
BufferAnchor, like deserializeVideoFrameView. A null anchor copies, exactly as
before.

A new name rather than an overload: builtin_object_codec.cpp (and any
consumer) takes the address of deserializePointCloud, which an overload would
make ambiguous.

Motivation (PJ4, Iris Xe): the host's per-sample copy of a 10M-point cloud
costs a memmove plus ~29k first-touch page faults per frame; with the view the
10M stream frame went from 137 to 71 ms of wall time.

MINOR: an additive client-side helper; host contract unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V3ZZU95hWdyWcCj8dQkmAi
@facontidavide
facontidavide merged commit bfc9972 into main Sep 28, 2026
7 checks passed
@facontidavide
facontidavide deleted the feat/pointcloud-zero-copy branch September 28, 2026 05:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant