Skip to content

Add BatchSpanProcessor option to set CPU affinity on the worker thread #1822

@bjosv

Description

@bjosv

Is your feature request related to a problem?
We would like to use the batch processor in a system where other system parts requires low latency and high throughput.
Today this is obtained by running the processes in a strict fashion and pinning threads to CPUs.

When using the batch processor it starts a worker thread which runs on any CPU, which gives degraded performance.

Describe the solution you'd like
We preferably would like to use the provided batch processor and one proposal would be that we add an CPU-affinity-mask option to the BatchSpanProcessorOptions.

When this option is configured we set the given cpu affinity using std::thread::native_handle on worker_thread_ and then set the mask via pthread_setaffinity_np(). This could possibly be a Linux only feature, but Windows has something similar via SetProcessAffinityMask().

Describe alternatives you've considered

  • Use the SimpleSpanProcessor without a thread, but we believe it might block. Async IO seems not yet available.
  • Own implementation of a batch processor.

Would a PR for a feature like this possibly be accepted?
Are there other options that I haven't yet considered?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions