PhotonLibOS
PhotonLibOS copied to clipboard
benchmark of context switch? (latency)
这个参数对我们的业务比较重要. 谢谢啊!
The context switch latency varies from 10 to 20 nano seconds depending how many coroutines you are running with.
We already have a test case for this. https://github.com/alibaba/PhotonLibOS/blob/0fa93f3e58d554f935ec62538d054f4d6595838f/thread/test/test.cpp#L380-L398
You can run it on your environment.
But I wonder why context switch is what you are concerned. It doesn't weigh too much in the whole IO process, only a small portion, I believe.
Can you describe your scenario?
10 to 20 nano seconds
wonderful, can not believe, as I know the bthread which is a coroutine in brpc context switch time is 2~3 us..........
But I wonder why context switch is what you are concerned. It doesn't weigh too much in the whole IO process, only a small portion, I believe.
Can you describe your scenario?
high frenquency trading. it is latency sensitive.
The context switch latency varies from 10 to 20 nano seconds depending how many coroutines you are running with.
We already have a test case for this.
https://github.com/alibaba/PhotonLibOS/blob/0fa93f3e58d554f935ec62538d054f4d6595838f/thread/test/test.cpp#L380-L398
You can run it on your environment.
In my computer, AMD Ryzen 7 3700X 8-Core Processor, 3.6G hz, single context switch is 182.6550 ns.
test_thread_switch:single context switch: 12.5599 ns (79.6185 M/s)
2.6 GHz Intel Core i7, macOS
@jiangdongzi Did you forget to add -O2? 182ns is too high