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

Compress server data #3

Closed
lgommans opened this issue Sep 13, 2016 · 1 comment
Closed

Compress server data #3

lgommans opened this issue Sep 13, 2016 · 1 comment
Milestone

Comments

@lgommans
Copy link
Owner

lgommans commented Sep 13, 2016

The data gets over half a megabyte during busy hours and is still a couple hundred kilobytes during slow hours. Some testing should be done with compression. Ideally, the decompressor should be small and very fast:

  • small because otherwise it defeats the whole purpose. If it's bigger than a few functions, thus requiring a separate file and probably adding another roundtrip, it already kind of defeats the purpose.
  • fast because we already spend enough CPU time parsing this monster.

I'm thinking of some simple string replacements, possibly making it a binary format, but my thoughts still focus on a substitution scheme for JSON. It's probably better to do some testing with existing algorithms like deflate, though I wonder how fast bitwise operations are going to be in Javascript (namely Huffman).

Compression time is not an issue, within bounds of course.

@lgommans lgommans added this to the 2.0 milestone Sep 13, 2016
@lgommans
Copy link
Owner Author

I had a go at this... and then discovered my server already gzips the data. My custom lz77 implementation was completely redundant, and while it was fine in Javascript, in PHP it was way too slow.

Additionally I have removed some unused fields (mod_crc and game_secret) from the data, making it smaller still.

The download size is currently under 100KB and I doubt it's going to get much better without a disproportional amount of work, so I am closing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant