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
PoC: C++ ASIO #4744
base: master
Are you sure you want to change the base?
PoC: C++ ASIO #4744
Conversation
I think ASIO is highly regarded so if we were starting from scratch, ASIO seems like a good choice. However, rewriting the existing networking code using ASIO seems like a lot of work and I'm not sure what we really gain from it. The current networking code has been very stable (not touched is 3-4 years). AFAIK, we also don't have any serious networking bugs or missing features that would justify such a major rewrite. |
I'm intending to do small steps, like this one, so definitely no thousand line diffs :) A migration would get us using
|
AFAICT, It also looks like ASIO uses the same "iocp" API, judging by the
Having separate threads for generating, lighting, etc. means the OS scheduler ensures some fairness between them. Imagine you queue 1000 chunks for generating and suddenly the server stops accepting client connections because the authenticator task doesn't get a chance to run. In a thread pool, you also need to be very careful about blocking code. e.g. the world storage thread wouldn't work as a thread pool task since it's based on blocking file IO. |
libevent is blocked in a select for me, but asio is in an iocp call Yeah good point with the fairness, certainly we shouldn't post work onto the io_context that's accepting connections. Such a pity there's no cross platform support for async file operations... In any case we're still some ways away from a thread pool, this PR is only for the networking side :) |
827478d
to
46d102c
Compare
Could you measure the difference in time between full rebuild of master as-is and with this PR? The problem with header-only libraries is that often they increase compilation times significantly. The Factorio team had to get rid of boost for this reason - it increased their build times by order of tens of minutes. |
Sure, hold on a bit. |
What do you guys think? It certainly has the potential to make networking much more succinct.