Open bhansconnect opened 1 month ago
On macos the posix backend is used, which doesn't have that great perf. You'd want to test on linux with io_uring which this library mainly targets. iocp may work okay as well. As for clean_up_tasks, I think it would be good idea to add ability so tasks can be detached so it won't be needed, in fact you may want to replace nop in cleanup_tasks with delay (and move it from the inner while to the outer one) as it seems that loop will be very busy otherwise causing lots of context switches.
It is now possible to detach tasks.
I'm guessing I'm fundamentally doing this wrong/in a poor form. Currently I am just trying to get a simple http server built on top of sockets and zig-aio. The performance tends to be quite sporadic. Overall, it is really poor.
On top of that, multiple threads look to make the performance worse. Or at a minimum don't really change the perf.
I have an 8 core machine, so I leave half of the cores for the server and half for a benchmarking tool. I have been benchmarking this super slim server impl with
wrk
:wrk -t 4 -c 32 -d 10 http://127.0.0.1:8000
. I also use-c 512
to do a high connection test.All tests on macos.
Overall, I'm mostly curious if I am using the library fundamentally wrong? Do you have any general suggestions on the most performant way to do something like this? I understand that my current impl will be missing tons of advanced scheduler features (like a work stealing queue), but given the simple requests and roughly even distributions of connections, I would expect that not to be a big deal.
I get the feeling that the issue I am hitting are fundamental to even the single threaded case. The only time I saw really good perf numbers was when running the handlers via a coro.ThreadPool. But the good perf would fall apart when the handlers block. Cause the thread pool would block fully instead of yielding to the scheduler.
Thanks for your work on this library, I totally understand if something like this is out of scope currently. I'm personally hoping that I am doing something silly in the code below and fixing it will give crazy perf boosts.