open-telemetry / open-telemetry/opentelemetry-cpp

SpinLockMutex : pause/yield instruction covering all the architectures/platforms

Open
#662 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area:api bug do-not-stale priority:p2
Dominant language
C++
Stars
1.4k
Forks
632
Avg merge
1d 13h
Merged PRs (30d)
75

Description

Describe your environment
Currently SpinLockMutex implementation performs std::atomic_bool.load() operation in loop until the lock is acquired. This will starve other logical CPU cores sharing the same load-store unit as the spinning core. To overcome the issue, it executes yield/pause instructions specific to architecture and/or platform in between as below:

https://github.com/open-telemetry/opentelemetry-cpp/blob/85d306f124b95c6935ecbd7c0f9e5662f76b9c21/api/include/opentelemetry/common/spin_lock_mutex.h#L90-L105

This ticket is raised to explore whether all the scenarios are covered and if not add yield/pause instruction for that platform/architecture.

Steps to reproduce
As above

What is the expected behavior?
All the platforms need to be covered.

What is the actual behavior?
There is TODO in code to add missing instructions for other platforms/archictecture.

Additional context
None

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 api/include/opentelemetry/common/spin_lock_mutex.h around lines 90-105, where SpinLockMutex loads the atomic flag and selects architecture- or platform-specific yield/pause instructions. Review the existing branches and TODO to determine which supported platforms or architectures are missing coverage; done means the relevant scenarios are covered without leaving the TODO unresolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
performance
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.