libaco icon indicating copy to clipboard operation
libaco copied to clipboard

Proposal: stack size of benchmark coroutines co_fp_stksz_xx() is optmized by compiler

Open guangqianpeng opened this issue 6 years ago • 1 comments

To avoid being optimized by the compiler, the benchmark coroutines co_fp_stksz_xx() and co_fp_alloca() use memset() . However, it failed on my machine (Ubuntu 16.04, Linux 4.15, gcc 5.4). We can use the following method to correct the stack size:

void do_not_optimize(void* value) {
  asm volatile("" : : "r,m"(value) : "memory");
}
void co_fp_stksz_128() {
    int ip[28];
    do_not_optimize(ip);
    // memset(ip, 1, sizeof(ip));
    while(1){
        aco_yield();
    }
    aco_exit();
}

guangqianpeng avatar Feb 19 '19 13:02 guangqianpeng

Thank you very much for your excellent proposal, @guangqianpeng :-)

I would like to add such modification in the next release, i.e. the v1.3.0 which I'm working on.

hnes avatar Feb 20 '19 11:02 hnes