[Toybox] Performance on compress.c

Yeongdeok Suh skyducks111 at gmail.com
Thu Jul 9 03:41:06 PDT 2015


I discovered slow decompression while testing gunzip.
I want to discuss about this improvement.

I gunzipped an 15MB *.tar.gz file on the ARM board, and it takes around 17
sec.
It's too slow, so I want to improve this for ARM based environment.
(x86 was okay)

As I debugged the src,
below while loop takes too much time when decoded huffman symbol is over
256.
I'm looking for the better methods but it's not easy.
Could you share your opinion?

(toys/pending/compress.c)
--Line:
381-------------------------------------------------------------------------------------
        // Use huffman tables to decode block of compressed symbols
      for (;;) {
        int sym = huff_and_puff(bb, lithuff);

        // Literal?
        if (sym < 256) data_crc(sym);

        // Copy range?
        else if (sym > 256) {
          int len, dist;

          sym -= 257;
          len = TT.lenbase[sym] + bitbuf_get(bb, TT.lenbits[sym]);
          sym = huff_and_puff(bb, disthuff);
          dist = TT.distbase[sym] + bitbuf_get(bb, TT.distbits[sym]);
          sym = TT.pos & 32767;

    //---------Slow! O(n^2)--------------------------
          while (len--) data_crc(TT.data[(TT.pos-dist) & 32767]);

        // End of block
        } else break;
      }
--Line:
403-------------------------------------------------------------------------------------


YD
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20150709/4ba9e772/attachment-0003.htm>


More information about the Toybox mailing list