question

Upvotes
Accepted
488 16 20 29

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 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
Upvotes
Accepted
791 11 16 20

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 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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