libaco
libaco copied to clipboard
Proposal: stack size of benchmark coroutines co_fp_stksz_xx() is optmized by compiler
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();
}
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.