Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Should i use zlib_encode for performance ?

Comments in 'Plugin Development' started by Inta, Jul 31, 2016.

  1. Inta
    Offline

    Inta Active Member

    Joined:
    Feb 11, 2016
    Posts:
    84
    Minecraft User:
    InstantlyTa
    I saved the Skin Data of players on a variable at the main part of the plugin.
    Should i save it like that or use zlib encode/decode? If yes then what level should i use to encode it?
    Also i always use that variable but not touching that section (multidimensional array), sometime reference, sometime clone it. Is that count?
    Last edited: Jul 31, 2016
  2. Extreme_Heat
    Offline

    Extreme_Heat Active Member

    Joined:
    Apr 19, 2016
    Posts:
    76
    Minecraft User:
    Extreme_Heat
    You use zlib for compression, not for performance. When you're sending data through a socket, you want to compress the data so it can get to the host as fast as possible. Decompression (and compression) require a certain amount of CPU usage that you give up, so you really have to consider if sending data as fast as possible is worth the performance hit. There is no reason you should be compressing when you don't have to, something like this could probably be stored in RAM if you need instant access. If you're storing something like this and you're fine with decompressing every time you need to access the data, then you should be using a compression level that matches how often you're going to access the data. If you're doing it frequent-ish, use the fastest compression level (1), etc.
    applqpak, Inta and AndrewBit like this.
  3. Inta
    Offline

    Inta Active Member

    Joined:
    Feb 11, 2016
    Posts:
    84
    Minecraft User:
    InstantlyTa
    So i should spend some RAM for data and unset it later rather than keep my CPU little more hot.
  4. SOFe
    Offline

    SOFe Banned

    Joined:
    May 28, 2016
    Posts:
    386
    Minecraft User:
    Herobrine
    If you want it possible to easily viewable by the user through GZIP openers (e.g. WinRAR), use the ZLIB_ENCODING_GZIP compression encoding. Otherwise, use ZLIB_ENCODING_DEFALTE for performance.

    Also see this StackOverflow question: http://stackoverflow.com/a/388633/3990767

Share This Page

Advertisement