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

Fiber.yield() very slow #320

Closed
simendsjo opened this issue Sep 21, 2013 · 3 comments
Closed

Fiber.yield() very slow #320

simendsjo opened this issue Sep 21, 2013 · 3 comments

Comments

@simendsjo
Copy link
Contributor

Ref: http://forum.rejectedsoftware.com/groups/rejectedsoftware.vibed/thread/4515/

I don't know any of druntime or vibe internals, so I have no idea how I can find out if this is expected.

I've located the slow code to be libevent2tcp.d -> leastSize -> mctx.core.yieldForEvent() -> Fiber.yield()

@MartinNowak
Copy link
Contributor

Calling Fibers is pretty fast, around 60ns per call on my machine.
It does trash the return stack of the CPU so there are some mispredictions.

import core.thread, std.datetime, std.stdio;

void main()
{
    scope fib = new Fiber({for (;;) Fiber.yield(); });
    auto sw = StopWatch(AutoStart.yes);
    foreach (i; 0 .. 1_000_000)
        fib.call();
    sw.stop();
    writeln(sw.peek.usecs);
}

@s-ludwig
Copy link
Member

This seems to be an instance of #338. Can you confirm that it runs fast again on the latest beta?

@s-ludwig
Copy link
Member

Closing until confirmed.

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

No branches or pull requests

3 participants