Skip to content

Add a tutorial for a small-buffer-optimized owning wide pointer - #465

Merged
jbcoe merged 1 commit into
mainfrom
jbcoe-wide-pointer-sbo
Oct 10, 2026
Merged

jbcoe merged 1 commit into
mainfrom
jbcoe-wide-pointer-sbo

Conversation

@jbcoe

@jbcoe jbcoe commented Oct 6, 2026

Copy link
Copy Markdown
Owner

No description provided.

@jbcoe jbcoe changed the title Jbcoe wide pointer sbo Add a tutorial for a small-buffer-optimized owning wide pointer Oct 6, 2026
@codecov

codecov Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.54%. Comparing base (3f8cbda) to head (b71fe3c).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #465   +/-   ##
=======================================
  Coverage   93.54%   93.54%           
=======================================
  Files          11       11           
  Lines         836      836           
  Branches       41       41           
=======================================
  Hits          782      782           
  Misses         26       26           
  Partials       28       28           
Flag Coverage Δ
consteval 90.15% <ø> (ø)
runtime 95.01% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jbcoe
jbcoe force-pushed the jbcoe-wide-pointer-sbo branch 6 times, most recently from e18f891 to b22eac2 Compare October 7, 2026 07:43
@jbcoe
jbcoe requested a review from RyanJK5 October 7, 2026 22:04
@jbcoe
jbcoe marked this pull request as ready for review October 7, 2026 22:05
@jbcoe
jbcoe removed the request for review from RyanJK5 October 7, 2026 22:05

@philipcraig philipcraig left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes for two things: the inactive-union-member access at line 116 (and 110), and tests for the two assignment operators. The other notes are suggestions.

Comment thread tutorials/07_wide_pointer_sbo.cc
Comment thread tutorials/07_wide_pointer_sbo.cc
Comment thread tutorials/07_wide_pointer_sbo.cc
Comment thread tutorials/07_wide_pointer_sbo.cc
Comment thread tutorials/07_wide_pointer_sbo.cc
Comment thread tutorials/07_wide_pointer_sbo.cc Outdated
@jbcoe
jbcoe marked this pull request as draft October 8, 2026 22:15
@jbcoe
jbcoe force-pushed the jbcoe-wide-pointer-sbo branch 3 times, most recently from de2d175 to e34c32f Compare October 9, 2026 13:01
@jbcoe
jbcoe requested a review from philipcraig October 9, 2026 13:54
@jbcoe
jbcoe marked this pull request as ready for review October 9, 2026 13:54
@jbcoe
jbcoe removed the request for review from philipcraig October 9, 2026 13:55
@jbcoe
jbcoe marked this pull request as draft October 9, 2026 13:55
@jbcoe
jbcoe force-pushed the jbcoe-wide-pointer-sbo branch 5 times, most recently from 1e6509b to 54f3685 Compare October 9, 2026 17:02
@jbcoe

jbcoe commented Oct 9, 2026

Copy link
Copy Markdown
Owner Author

I'm not worried about code coverage results for tutorial code.

@jbcoe
jbcoe force-pushed the jbcoe-wide-pointer-sbo branch from 54f3685 to cf702dd Compare October 9, 2026 17:17
@jbcoe

jbcoe commented Oct 9, 2026

Copy link
Copy Markdown
Owner Author

@RyanJK5 once this tutorial PR looks ok, did you want to try adding SBO support to protocol?

@jbcoe
jbcoe force-pushed the jbcoe-wide-pointer-sbo branch from cf702dd to 6df5cc7 Compare October 9, 2026 17:24
@jbcoe
jbcoe marked this pull request as ready for review October 9, 2026 17:25
@jbcoe
jbcoe requested review from RyanJK5 and philipcraig October 9, 2026 17:25
@RyanJK5

RyanJK5 commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

@RyanJK5 once this tutorial PR looks ok, did you want to try adding SBO support to protocol?

Happy to!

@RyanJK5 RyanJK5 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Comment thread tutorials/07_wide_pointer_sbo.cc
Comment thread tutorials/07_wide_pointer_sbo.cc Outdated
Comment thread tutorials/07_wide_pointer_sbo.cc Outdated
Comment thread tutorials/07_wide_pointer_sbo.cc Outdated
@jbcoe
jbcoe force-pushed the jbcoe-wide-pointer-sbo branch 3 times, most recently from 42f8db5 to bb531ae Compare October 10, 2026 08:12
@jbcoe
jbcoe requested review from RyanJK5 and philipcraig and removed request for philipcraig October 10, 2026 08:16

@philipcraig philipcraig left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both earlier points are fixed. Two suggestions below.

Comment thread tutorials/07_wide_pointer_sbo.cc
Comment thread tutorials/07_wide_pointer_sbo.cc Outdated
@jbcoe
jbcoe force-pushed the jbcoe-wide-pointer-sbo branch from bb531ae to 76fe976 Compare October 10, 2026 09:58
Wide pointer SBO initial pass


Fix object lifetime bugs in the SBO wide pointer tutorial

Free indirect storage on destroy. Leave a moved-from buffer object in
place for its owner to destroy, and destroy moved-from objects in swap
before reusing their storage. Constrain the forwarding constructor and
use the decayed type. Static assert that the type fits the buffer.
Initialise CountOps::ops_ and copy it in the copy constructor.

Address review of the SBO wide pointer tutorial

Select storage with BufferStorage/IndirectStorage tag types so buffer
requirements apply only to buffer storage, and make the constructors
explicit. Use std::launder for buffer access and static_cast from
void*. Make swap noexcept and drop redundant self-checks and defaulted
members. Add missing includes and brief prose. Rename the target to
wide_pointer_sbo_tutorial and drop unused Bazel dependencies.

Raise coverage of the SBO wide pointer tutorial

Add tests that copy an indirect pointer, copy and move an empty
pointer, and check a copied buffer object is destroyed. Ignore
tutorials in Codecov, as for the other test files.

Reduce clang-tidy suppressions


Consolidate and simplify tests


Add missing include


Use std::size_t

Add tutorial for a SBO-optimized wide pointer

Wide pointer narrowing

Check storage kind and copy count in copy-assignment tests

Start the buffer's lifetime in the buffer-storage constructor


Disable clang-tidy for the SBO wide pointer tutorial

Use placement new to activate the buffer and re-enable clang-tidy

Simplify the SBO tutorial's moved-from comment

Tidy the SBO tutorial and check the target of move-assignment

Use std::construct_at to activate the buffer

Give the SBO wide pointer's copy-assignment the strong guarantee
@jbcoe
jbcoe force-pushed the jbcoe-wide-pointer-sbo branch from 209e4e7 to b71fe3c Compare October 10, 2026 10:00
@jbcoe
jbcoe merged commit aefb701 into main Oct 10, 2026
24 checks passed
@jbcoe
jbcoe deleted the jbcoe-wide-pointer-sbo branch October 10, 2026 19:22
@jbcoe
jbcoe removed the request for review from RyanJK5 October 10, 2026 19:22
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.

3 participants