opentelemetry-cpp icon indicating copy to clipboard operation
opentelemetry-cpp copied to clipboard

SpinLockMutex small cleanup; improved and extended benchmark

Open Reneg973 opened this issue 2 months ago • 4 comments

Fixes # (issue)

Changes

  • load() not required in try_lock()
  • shortened loop in lock()
  • fixed erroneous yield() in BM_ThreadYieldSpinLockThrashing
  • added std::mutex to benchmark
  • removed superfluous static as code is already in unnamed namespace

It seems that at least on Apple M1 (lClang+libc) the std::mutex outperforms SpinlockMutex with higher number of threads.

Reneg973 avatar Oct 19 '25 21:10 Reneg973

CLA Signed

The committers listed above are authorized under a signed CLA.

  • :white_check_mark: login: dbarker / name: Doug Barker (b994d0d7f41487c1b9b97543dd3a8b31b1b8a83f)

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 89.91%. Comparing base (907277c) to head (b994d0d).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3706      +/-   ##
==========================================
- Coverage   89.91%   89.91%   -0.00%     
==========================================
  Files         225      225              
  Lines        7134     7132       -2     
==========================================
- Hits         6414     6412       -2     
  Misses        720      720              
Files with missing lines Coverage Δ
api/include/opentelemetry/common/spin_lock_mutex.h 100.00% <100.00%> (ø)
:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Oct 20 '25 20:10 codecov[bot]

I'm confused why this CI/Format check fails! Any hint is welcome

Reneg973 avatar Oct 24 '25 19:10 Reneg973

@Reneg973

Tip to format all the code (C++, CMake, Bazel):

[malff@malff-desktop ~]$ more ~/bin/otel_cf.sh 
#!/bin/bash
podman run --rm --privileged=true --volume ${PWD}:/otel otel/cpp_format_tools

See https://github.com/open-telemetry/cpp-build-tools/tree/main/cpp_format_tools

marcalff avatar Oct 25 '25 19:10 marcalff