Skip to content

Conversation

@mingxwa
Copy link
Member

@mingxwa mingxwa commented Mar 1, 2025

New Features

  • Function template allocate_proxy_shared()
  • Function template make_proxy_shared()
  • Class template weak_facade
  • Alias template weak_proxy
  • Member type basic_facade_builder::support_weak_ownership (compatible with std::weak_ptr)

Comparing to std::shared_ptr

  • std::shared_ptr implements type erasure on the deleter with a cost. It is not needed for proxy.
  • std::shared_ptr implements conversion to std::weak_ptr with a cost. proxy can opt-out if weak ownership is not desired. From GitHub search result, std::shared_ptr has 3.9M occurrences, while std::weak_ptr only has 156k occurrences (4%). allocate_proxy_shared() and make_proxy_shared() can optimize the implementation at compile-time based on whether support_weak_ownership is specified by a facade type.
  • std::shared_ptr supports creation from a raw pointer, leading to limitations in implementing a space-efficient memory layout. std::shared_ptr maintains the object and the control block in two parts. Although std::make_shared can avoid another allocation, it at least allocates a space to store the address of the object, which can be eliminated (similar to boost::intrusive_ptr).

Testing

  • Switched to the latest libc++ when building with Clang on Ubuntu
  • Added 23 unit test cases.
  • Added 8 benchmarks and 6 metrics

@mingxwa mingxwa requested review from Copilot, guominrui and tian-lt March 1, 2025 10:42
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

PR Overview

This PR introduces new facilities for shared/weak ownership by adding several new types and function templates while optimizing for compile-time decisions.

  • Introduces concepts and templates for shared and weak ownership models.
  • Updates the build workflow to install the libc++-18-dev package and configure clang build flags for consistent standard library usage.

Reviewed Changes

File Description
.github/workflows/bvt-clang.yml Adds libc++-18-dev installation and "-stdlib=libc++" flag for clang builds

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

@mingxwa mingxwa merged commit 9659c99 into microsoft:main Mar 3, 2025
7 checks passed
@mingxwa mingxwa deleted the user/mingxwa/shared branch March 3, 2025 11:06
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