Hello. In 2019 year we have a great amount of ram available. So we can reach max possible performance for lzw (with clear) algorithm.
The idea is simple: we can use sparse array instead of double hashing array as dictionary.
Please imagine big array where (code << 8) | symbol => next_code. symbol is between 0, 255, code between 0 and (2 ** 16) - 1 and next_code between 257 and (2 ** 16) - 1. 33.5 MB ram is required for such array.
The problem is that we have to clear sparse array. For example we have to clear dictionary 2040 times for compressing 850 MB linux-4.20.3.tar. 33.5 MB * 2040 ~ 68 GB. I've solved this issue by collecting used sparse array indexes in separate array and clear just these indexes.
The complexity of insert or find is still O(1). You can find docs here. Implementation is here.
I am about to be sure that ncompress won't accept such huge memory eater. I want just to inform people. Thank you.
Hello. In 2019 year we have a great amount of ram available. So we can reach max possible performance for lzw (with clear) algorithm.
The idea is simple: we can use sparse array instead of double hashing array as dictionary.
Please imagine big array where
(code << 8) | symbol => next_code.symbolis between0,255,codebetween0and(2 ** 16) - 1andnext_codebetween257and(2 ** 16) - 1.33.5 MBram is required for such array.The problem is that we have to clear sparse array. For example we have to clear dictionary 2040 times for compressing
850 MBlinux-4.20.3.tar.33.5 MB * 2040 ~ 68 GB. I've solved this issue by collecting used sparse array indexes in separate array and clear just these indexes.The complexity of insert or find is still O(1). You can find docs here. Implementation is here.
I am about to be sure that ncompress won't accept such huge memory eater. I want just to inform people. Thank you.