open-telemetry / open-telemetry/opentelemetry-cpp

Rework batch processor to elaborate in code comments / avoid while(...) loops

Open
#477 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

There's a code in Batch Log processor that contains the following constructs:

  while (is_force_flush_.load() == true)
  {
    cv_.notify_one();
  }

These constructs look suspicious, as "what if" the other thread does not refresh the is_force_flush value - does it mean that we are effectively busy-waiting, burning CPU cycles?

Should this be supplemented with some timed idle-wait or with std:🧵:yield , or reworked using conditional variables?

Discussed with @open-telemetry/cpp-approvers during SIG call that the code as it is coded - looks funky, but should be fine .. Let's see if it can be reworked long-term to look cleaner.

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 locating the Batch Log processor and the while loop checking is_force_flush_.load(), then review the surrounding condition-variable and notification logic. Compare the current behavior with the issue's proposed timed wait, yield, or conditional-variable approaches; done means a cleaner design that avoids unnecessary busy-waiting without changing force-flush behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
observability-sre
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.