microsoft / microsoft/STL

atomic.cpp: Pool of spinlocks for shared_ptr instead of just single one

Open
#618 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Pass pointer value of control block of shared_ptr and select an instance of spin lock based on pointer bits. Spinlocks can reside in a static array, they should be std::hardware_destructive_interference_size away.

Targets scenario of std::vector<std::shared_ptr<T>>> parallel copying. After contention for some lock, threads would by copying different pieces in case of fix is there. Currently I believe one would block others until it has done copying (due to the "unfairness").

This is not the same as #370 , these are separate issues, they address different scenarios, and each could be fixed separately from the other.

This one is ABI breaking as currently _Lock_shared_ptr_spin_lock() / _Unlock_shared_ptr_spin_lock() do not take parameters.

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 with the _Lock_shared_ptr_spin_lock() and _Unlock_shared_ptr_spin_lock() entry points and review the vNext compatibility note linked from the issue. The work is complete when shared_ptr control-block pointer bits select among cache-line-separated spinlocks and the associated ABI changes are addressed on the vNext branch.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.