test-coroutine: test cost introduced by coroutine
PATCH 1/1 test-coroutine: test cost introduced by coroutine
This test runs dummy function with coroutine by using two enter and one yield since which is a common usage.
So we can see the cost introduced by corouting for running one function, for example:
Run operation 20000000 iterations 4.841071 s, 4131K operations/s 242ns per coroutine
--- tests/test-coroutine.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
tests/test-coroutine.c +30 -0
@@ -311,6 +311,35 @@ static void perf_baseline(void) maxcycles, duration); } +static __attribute__((noinline))void perf_cost_func (void *opaque) +{ +qemu_coroutine_yield (); +} + +static void perf_cost (void ) +{ +const unsigned long maxcycles =40000000 ; +unsigned long i =0 ; +double duration; +unsigned long ops; +Coroutine *co; + +g_test_timer_start (); +while (i++ < maxcycles) { + co =qemu_coroutine_create (perf_cost_func); +qemu_coroutine_enter (co, &i); +qemu_coroutine_enter (co,NULL ); + } + duration =g_test_timer_elapsed (); + ops = (long )(maxcycles / (duration *1000 )); + +g_test_message ("Run operation %lu iterations %f s, %luK operations/s, " +"%luns per coroutine" , + maxcycles, + duration, ops, + (unsigned long )(1000000000 * duration) / maxcycles); +} +int main (int argc,char **argv) {g_test_init (&argc, &argv,NULL );
@@ -325,6 +354,7 @@ int main(int argc, char **argv)g_test_add_func ("/perf/nesting" , perf_nesting);g_test_add_func ("/perf/yield" , perf_yield);g_test_add_func ("/perf/function-call" , perf_baseline); +g_test_add_func ("/perf/cost" , perf_cost); }return g_test_run (); }
Signature · 1 line
1.7.9.5
Quoted 28 lines · Ming Lei
This test runs dummy function with coroutine by using two enter and one yield since which is a common usage.
So we can see the cost introduced by corouting for running one function, for example:
Run operation 20000000 iterations 4.841071 s, 4131K operations/s 242ns per coroutineSigned-off-by Ming Lei <[email protected]>--- tests/test-coroutine.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)tests/test-coroutine.c +6
-0@@ -311,6 +311,35 @@ static void perf_baseline(void) maxcycles, duration); } +static __attribute__((noinline))void perf_cost_func (void *opaque) +{ +qemu_coroutine_yield (); +} + +static void perf_cost (void )
tests/test-coroutine.c static void perf_baseline(void) · line 329
Quoted 10 lines
tests/test-coroutine.c +10
-0+{ +const unsigned long maxcycles =40000000 ; +unsigned long i =0 ; +double duration; +unsigned long ops; +Coroutine *co; + +g_test_timer_start (); +while (i++ < maxcycles) { + co =qemu_coroutine_create (perf_cost_func);
I am not sure qemu_coroutine_create is systematically used. I rather believe the code try to reuse existing coroutine.
Quoted 28 lines
tests/test-coroutine.c +14
-0+qemu_coroutine_enter (co, &i); +qemu_coroutine_enter (co,NULL ); + } + duration =g_test_timer_elapsed (); + ops = (long )(maxcycles / (duration *1000 )); + +g_test_message ("Run operation %lu iterations %f s, %luK operations/s, " +"%luns per coroutine" , + maxcycles, + duration, ops, + (unsigned long )(1000000000 * duration) / maxcycles); +} +int main (int argc,char **argv) {g_test_init (&argc, &argv,NULL );@@ -325,6 +354,7 @@ int main(int argc, char **argv)g_test_add_func ("/perf/nesting" , perf_nesting);g_test_add_func ("/perf/yield" , perf_yield);g_test_add_func ("/perf/function-call" , perf_baseline); +g_test_add_func ("/perf/cost" , perf_cost); }return g_test_run (); }Signature · 1 line
1.7.9.5
Quoted 34 lines · Benoît Canet
Quoted 33 lines · Ming Lei
This test runs dummy function with coroutine by using two enter and one yield since which is a common usage.
So we can see the cost introduced by corouting for running one function, for example:
Run operation 20000000 iterations 4.841071 s, 4131K operations/s 242ns per coroutineSigned-off-by Ming Lei <[email protected]>--- tests/test-coroutine.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)tests/test-coroutine.c +11
-0@@ -311,6 +311,35 @@ static void perf_baseline(void) maxcycles, duration); } +static __attribute__((noinline))void perf_cost_func (void *opaque) +{ +qemu_coroutine_yield (); +} + +static void perf_cost (void ) +{ +const unsigned long maxcycles =40000000 ; +unsigned long i =0 ; +double duration; +unsigned long ops;
Quoted 8 lines
tests/test-coroutine.c static void perf_baseline(void) · line 329
Quoted 5 lines
tests/test-coroutine.c +5
-0+Coroutine *co; + +g_test_timer_start (); +while (i++ < maxcycles) { + co =qemu_coroutine_create (perf_cost_func);I am not sure
qemu_coroutine_createis systematically used. I rather believe the code try to reuse existing coroutine.
Isn't it what the coroutine pool is for? Is there really code duplicating it manually?
Quoted 31 lines
tests/test-coroutine.c static void perf_baseline(void)
Quoted 8 lines
tests/test-coroutine.c +7
-0+qemu_coroutine_enter (co, &i); +qemu_coroutine_enter (co,NULL ); + } + duration =g_test_timer_elapsed (); + ops = (long )(maxcycles / (duration *1000 )); + + g_test_message("Run operation %lu iterations %f s, %luKoperations/s, "
tests/test-coroutine.c static void perf_baseline(void)
Quoted 4 lines
tests/test-coroutine.c +4
-0+"%luns per coroutine" , + maxcycles, + duration, ops, + (unsigned long)(1000000000 * duration) /maxcycles);
Quoted 17 lines
tests/test-coroutine.c +3
-0+} +int main (int argc,char **argv) {g_test_init (&argc, &argv,NULL );@@ -325,6 +354,7 @@ int main(int argc, char **argv)g_test_add_func ("/perf/nesting" , perf_nesting);g_test_add_func ("/perf/yield" , perf_yield);g_test_add_func ("/perf/function-call" , perf_baseline); +g_test_add_func ("/perf/cost" , perf_cost); }return g_test_run (); }Signature · 1 line
1.7.9.5
Signature · 1 line
Gabriel
Quoted 34 lines · Benoît Canet
Quoted 33 lines · Ming Lei
This test runs dummy function with coroutine by using two enter and one yield since which is a common usage.
So we can see the cost introduced by corouting for running one function, for example:
Run operation 20000000 iterations 4.841071 s, 4131K operations/s 242ns per coroutine
Signed-off-by Ming Lei <[email protected]>--- tests/test-coroutine.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)tests/test-coroutine.c +11
-0@@ -311,6 +311,35 @@ static void perf_baseline(void) maxcycles, duration); } +static __attribute__((noinline))void perf_cost_func (void *opaque) +{ +qemu_coroutine_yield (); +} + +static void perf_cost (void ) +{ +const unsigned long maxcycles =40000000 ; +unsigned long i =0 ; +double duration; +unsigned long ops;
Quoted 8 lines
tests/test-coroutine.c static void perf_baseline(void) · line 329
Quoted 5 lines
tests/test-coroutine.c +5
-0+Coroutine *co; + +g_test_timer_start (); +while (i++ < maxcycles) { + co =qemu_coroutine_create (perf_cost_func);I am not sure
qemu_coroutine_createis systematically used. I rather believe the code try to reuse existing coroutine.
In block layer, it is a common usage, please see bdrv_co_aio_rw_vector(), and most of times the allocation hits on the pool, as mentioned by Gabriel Kerneis(). In this test, it should always be from the pool.
Ming
Quoted 29 lines
Quoted 29 lines
tests/test-coroutine.c +14
-1+qemu_coroutine_enter (co, &i); +qemu_coroutine_enter (co,NULL ); + } + duration =g_test_timer_elapsed (); + ops = (long )(maxcycles / (duration *1000 )); + +g_test_message ("Run operation %lu iterations %f s, %luK operations/s, " +"%luns per coroutine" , + maxcycles, + duration, ops, + (unsigned long )(1000000000 * duration) / maxcycles); +} +int main (int argc,char **argv) {g_test_init (&argc, &argv,NULL );@@ -325,6 +354,7 @@ int main(int argc, char **argv)g_test_add_func ("/perf/nesting" , perf_nesting);g_test_add_func ("/perf/yield" , perf_yield);g_test_add_func ("/perf/function-call" , perf_baseline); +g_test_add_func ("/perf/cost" , perf_cost); }return g_test_run (); } --1.7.9.5
Hi Guys,
Quoted 10 lines · Ming Lei
This test runs dummy function with coroutine by using two enter and one yield since which is a common usage.
So we can see the cost introduced by corouting for running one function, for example:
Run operation 20000000 iterations 4.841071 s, 4131K operations/s 242ns per coroutine
Signed-off-by Ming Lei <[email protected]>
Ping...
Thanks,
Kevin Wolf
AppliedAm 13.08.2014 um 12:08 hat Ming Lei geschrieben:
Quoted 10 lines
This test runs dummy function with coroutine by using two enter and one yield since which is a common usage.
So we can see the cost introduced by corouting for running one function, for example:
Run operation 20000000 iterations 4.841071 s, 4131K operations/s 242ns per coroutineSigned-off-by Ming Lei <[email protected]>
Thanks, applied to the block branch.
Kevin