microsoft / microsoft/STL

`<exception>`: Optimize `exception_ptr` a bit

Open
#6,387 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

performance
Dominant language
C++
Stars
11.1k
Forks
1.7k
Avg merge
4d 15h
Merged PRs (30d)
22

Description

It seems that we can optimize exception_ptr a bit without breaking ABI, given the internal implementation details actually use shared_ptr.

The following is possibly the full list but I'm not very sure.

  • the default constructor and constructor from nullptr_t can just rely on the default member initializers (initializing both internal pointer members to nullptr).
  • the swap function can just std::swap both pointer members.
  • the operator== can just compare _Data1 (which is equal to the result of get() of the internally reinterpreted shared).
  • the assignment operator from nullptr_t can swap *this with the empty exception_ptr first, which avoids one uninlined call to __ExceptionPtrAssign.
  • operator bool() can just return _Data1 != nullptr.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the exception_ptr implementation and its internal shared_ptr representation, focusing on the default and nullptr constructors, swap, equality, nullptr assignment, and operator bool. Verify the proposed changes against the existing ABI assumptions; done means these operations are optimized without breaking ABI.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.