ASIO threads currently spend most of their time performing XTea decryption/encryption. It might be worth allowing multiple threads to execute asio::io_service::run() to parallelize execution of XTea for multiple clients.
There is two details that must be addressed:
Dispatcher also waste time doing xtea encryption. Its happens when dispatcher calls Connection::send and there is no msg in the queue(the dispatcher will call Connection::internalSend to do the encryption and async asio send).
Another thing is that inside ProtocolGame::onRecvFirstMessage there is some calls to IOBan and IOLoginData functions that uses the main database connection. The main database connection has a lock which means if dispatcher is using the database connection the ASIO thread will waste time waiting the lock to be release.
I have vectorized code for XTEA and it could improve performance by up to 8x. I will open a PR soon.
Most helpful comment
I have vectorized code for XTEA and it could improve performance by up to 8x. I will open a PR soon.