Skip to content
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

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

Open
guangqianpeng opened this issue Feb 19, 2019 · 1 comment

Comments

@guangqianpeng
Copy link

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();
}
@hnes
Copy link
Owner

hnes commented Feb 20, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants