question

Upvotes
Accepted
488 12 13 27

Channel.write() best practices

I am developing a provider application and from some tests that I have done, it seems that writing to the same channel from multiple threads gives lower throughput than using just only one thread to call Channel.write().

Also, from the upajProvPerf source code, it uses only one thread to write to a channel and even though we can increase the number of threads via the ‘-threads’ option, more threads seems to be used to handle more connections/channels rather than to improve write speed/throughput.

Is the best practice to write to a channel is to call Channel.write() from a single thread?

elektronrefinitiv-realtimeelektron-sdktrepmulti-threadingperformance
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

1 Answer

Upvotes
Accepted
791 9 7 14

Yes, performance is best when writing from a single thread. Multiple threads result in lock contention while writing and slow things down.

The lock is applied on a per channel basis. You can use one thread per channel each with a single thread for multiple threads.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 5.0 MiB each and 10.0 MiB total.

Click below to post an Idea Post Idea