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
Compress GAME_START message #3870
Conversation
3982e29
to
25d71f4
Compare
@@ -920,7 +921,7 @@ void ServerApp::SendNewGameStartMessages() { | |||
m_universe, GetSpeciesManager(), | |||
GetCombatLogManager(), GetSupplyManager(), | |||
player_info_map, m_galaxy_setup_data, | |||
use_binary_serialization)); | |||
use_binary_serialization, boost::iostreams::zlib::default_compression)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are there plans to do something other than default_compression
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose it possible to introduce some option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm working on porting over the user option and client-server compression usage requests from #3854. Since those work as bool flags, my message creation functions look like:
Message MakeMessage(const std::string& data, bool use_compression) {
std::ostringstream os;
{
boost::iostreams::zlib_params params;
params.level = boost::iostreams::zlib::no_compression;
if (use_compression)
params.level = boost::iostreams::zlib::default_compression;
boost::iostreams::filtering_ostream zos;
zos.push(boost::iostreams::zlib_compressor(params));
zos.push(os);
freeorion_xml_oarchive oa(zos);
oa << BOOST_SERIALIZATION_NVP(data);
}
return Message{Message::MessageType::SOME_MSG, std::move(os).str()};
}
Would it be preferable for the user option to be the compression level, rather than just a true/false toggle?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hard to say, in most cases big messages are sent from server to client.
Add compression option to message creation functions. Based on freeorion#3870.
Here's the code for the user options and client-server compression usage requests. I have no idea how to perform Git operations between GitHub forks, so patch files it is. master...mlam19:msg_data_cpr_v 0001-Stream-based-compression-decompression.patch.txt |
I think we don't need compression for every message because many of them are quite small. |
That's fair. I think the messages that tend to get very large are:
|
CHAT_HISTORY tend to be large too. |
0001-Message-compression.patch.txt
EDIT: Updated patch with changes to more message creation calls. filtering_ostream::reset() readded but seems to cause server crash in Message::ChatHistoryMessage(). |
@mlam19 Did you catch issue with it? |
Since the last patch, I've found and set some more use_compression flags in various message creation calls. So now the server crash occurs when filtering_ostream::reset() is used is in Message::ChatHistoryMessage() when a remote client joins a game. I added some debug messages and exception handling.
The last messages in the server log are the "D1" and "D2" debug messages. Nothing appears in the terminal. |
By "when" do you mean "if"? Because if the log message for "D2" appears in the log, then the |
Yes, the "D1" and "D2" indicates that the If the |
Found my problem. The Here's the updated patch: |
Add compression for large messages. Disable compression for localhost clients. Based on freeorion#3870.
I've made a new pull request (#3904) with the patch. |
Add compression for large messages. Disable compression for localhost clients. Based on #3870.
Alternative approach to #3854
It also breaks some compatibility but enforces only limited messages to be compressed.