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

CPU load ? #23

Closed
zigster64 opened this issue Mar 5, 2021 · 4 comments
Closed

CPU load ? #23

zigster64 opened this issue Mar 5, 2021 · 4 comments

Comments

@zigster64
Copy link

Just running the basic example, Im seeing 100% CPU on 1 core.

?? Not sure if I have configured something wrong, or if Im on a particularly bad release of zig-master with a broken std.net.

Anyway - ApplePie is idling in var connection = stream.accept() catch |err| switch (err) { in src/server.zig ... so that suggest that zig std.net is eating all the CPU.

Curious, will have a deeper play tomorrow.

@zigster64
Copy link
Author

zigster64 commented Mar 5, 2021

followup - tried with different build options (as this is actually a benchmarking exersize comparing output to Go / Crystal / Rust)

When built with -Drelease-fast=true ... the benchmarking results using siege are absurdly good compared to regular debug build (which is slightly better than Go / Crystal)

Wasnt expecting that. (fast build has about 1% of the error rate, and is reporting 10x the transactions processed - weird !)

@zigster64
Copy link
Author

zigster64 commented Mar 5, 2021

Cancel that - I tried the same with https://github.com/Vexu/routez and got the exact same results

... 100% CPU on 1 core when waiting for socket connections through zig std.net
... massive benchmark improvement when building with -Drelease-fast=true

So the "problem" - if there is one - is higher up the chain. Nothing to do with ApplePie.

Also - changing the io_mode to .blocking solves the CPU issue
So with .blocking io_mode, and -Drelease-fast=true
The benchmark results v Go very very good.

closing

@Luukdegram
Copy link
Owner

Hi @zigster64, Thank you for reporting this nonetheless.
accept() should be a blocking call (theoretically) but it isn't atm. Currently, there are quite some issues upstream with regards to the event loop and I believe there's an idea to improve it soon, but I'm not sure what the exact details of those are. Just wanted to let you know :)

@zigster64
Copy link
Author

ziglang/zig#8224 is on the radar now :)

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

2 participants