microsoft / microsoft/STL

<mutex>: Further improve call_once performance by using atomic CAS and WaitOnAddress

Open
#707 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

More aggressive in direction of #606

Call once on atomic operations, directly in header, something like what currently call_once XP fallback is, but doing std::atomic<char>::wait instead of continuous spinning.

(std::atomic<char>::wait will spin a bit by itself before going to kernel wait, either inside WaitOnAddress or in a fallback)

So fast path is header only and fully inlined into caller.

ODR-breaking, since stopping using INIT_ONCE structure.

vNext note: Resolving this issue will require breaking binary compatibility. We won't be able to accept pull requests for this issue until the vNext branch is available. See #169 for more information.

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 issue #606 and the current call_once XP fallback, then examine how INIT_ONCE is used and where the implementation is exposed in headers. The proposed direction is atomic CAS with std::atomic<char>::wait and WaitOnAddress; completion depends on the vNext branch because the change breaks binary compatibility.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
operating-systems, performance
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.