-
Notifications
You must be signed in to change notification settings - Fork 1.6k
test: Add perf test to measure the "cost" of chain wakeup #2599
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Please normalize by the depth, or at least add the depth to the test name. It's not then_value that takes 1 usec, it's 32 of them. |
@xemul thanks. This is very important. |
Makes sense I guess as every co_await in the chain involves a throw-catch and those are the expensive part (high fixed cost, and also a cost per frame unwound though I guess there are very few frames unwound for each throw/catch here). |
The test creates a chain of future-promise-s and then wakes up the last one thus causing the cascade of resolutions. There are 2x2 tests -- resolve with value or exception vs co_await-ed or .then()-d chains. The result is (depth of 32) test iterations median mad min max allocs tasks inst cycles chain.then_value 29944640 33.158ns 0.026ns 33.059ns 33.740ns 1.063 1.094 314.9 0.0 chain.await_value 18963648 52.668ns 0.242ns 52.426ns 54.334ns 1.094 1.125 414.3 0.0 chain.then_exception 29095808 33.633ns 0.093ns 33.541ns 35.308ns 1.094 1.094 316.3 0.0 chain.await_exception 325344 3.112us 17.301ns 3.083us 3.192us 2.156 1.125 23489.0 0.0 Waking up co-await-ed chain with exceptions is extremely expensive. The result with depth of 8 are the same, which means that exception propagation via co-awaits is expensive on _every_ co_await, as it "scales" linearly with the chain depth. Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
9303523
to
5a2414b
Compare
upd:
upd-upd:
|
|
@avikivity , please consider merging |
It is a possible explanation but a closer look at the implementation is required. |
@avikivity , please consider merging |
test: Add perf test to measure the "cost" of chain wakeup
The test creates a chain of future-promise-s and then wakes up the last one thus causing the cascade of resolutions. There are 2x2 tests -- resolve with value or exception vs co_await-ed or .then()-d chains.
The result is (depth of 32)
Waking up co-await-ed chain with exceptions is extremely expensive.
The result with depth of 8 are the same, which means that exception propagation via co-awaits is expensive on every co_await, as it "scales" linearly with the chain depth.