LZ77 model:
    -no lz if len small and dist large: don't have much sense with our MINLEN=4
    -hash4+3: only 1% gain even on ghc.exe
    -hash5+4: 48->46.7 mb but 2x slower (22->46sec: 240mb compressed using 16mb hash)
    -0x65a8e9b4 for hash
    +combined len+dist encoding a-la cabarc - will make decoding a bit faster, but who cares? :)
    -save into hash records unused part of hash value in order to make
        fast check of usability of this hash slot (like it is already
        done in REP); would be especially helpful on larger hashes
    -save into hash record 4 bits of p[5] - would be useful to skip trying second..fourth hash records
    +save into hash record 4 bytes of data
    +lazy search (and return of 3-byte strings) for highest compression mode
+l8... -  1      280 
+compare with ideal hash function crc+crc+..
    (((CRCTab[(x)&255] ^ _rotr(CRCTab[((x)>>8)&255],8) ^ _rotr(CRCTab[((x)>>16)&255],16) ^ _rotr(CRCTab[((x)>>24)&255],24)) >> HashShift) & HashMask)
+store unused hash bits + a few more chars in hash   (1.5x speedup)
    491->367 (340 for hash4x), 91->68, 51->43 secs
    +     4 
    +   len=3,4,5,6
    + t,      7   len3..5     
          -
+fast arithmetics! total=2^n
         ;   bits+arith    
+lazy matches                                        (+3.5% compression)
    unsuccessfully tried:
      ush good_length; - reduce lazy search above this match length
      ush max_lazy;    - do not perform lazy search above this match length
      ush nice_length; - quit search above this match length
+arith / huffman / bitio                         (+10% compresion for bit i/o, +20% for huffman)
    byte i/o -> class: +0.3 sec on !all
+3-byte strings
+   
    +    0.3%     6- 
+better hash multiplier
-5% less compression of src (l4 h22) compared to mmdet. strange?
-several encoding tables: after char, after small string, large string
-add custom MF for l=4/8 (3/6?) what means -1 sec. on !all
    don't have much meaning because caching MF isn't any worser
+FIXED: MatchFinder2   3-  / lazy matching (update_hash       3 )
+FAST_COMPILE - only 4 models actually used by -1..-12
+ hash_row_width   MatchFinder
+FIXED: caching MF -       
+sliding window for higher modes (-4/-5 - m.buffer/2, -6 and up - m.buffer/4)
+write data to outstreams in 16mb chunks
+64k-1m non-sliding window for -1..-3
+improved caching MF - memory accesses only for matches>=7 or last check
-max_lazy may improve speed/ratio for -4..-6 modes
-don't check more than one real string (option? only for 2-element hash?)
    -skip checking second string if first is large enough
+[almost] full hash_update for highest modes
+IMPOSSIBLE_LEN/IMPOSSIBLE_DIST for EOF encoding, encode() for first 2 chars
+FIXED: -s- -p2 problem (was returning len==0 instead of MINLEN-1)
- lazy    . ,  3-   4- 
+TOO_FAR checks moved into caching MF
+output buffer now flushed only when reading next input chunk
+tor_(de)compress - returns error code or FREEARC_OK
+freearc:      
+7z's lazy heuristic
  +   - if newlen=len+1 and newdist>dist*64 - ignore it
+2-byte strings, +repdist, +repboth, +repchar
+  !
+ bytecoder
  +large len - a few bytes representation to ensure no overflows
+auto-decrease hash (and buf) for small files
+  next match  lazy matcher
-repdistN+-delta - 0.4%  
+HuffmanEncoder::encode2
+fixed:     REPCHAR   repdist0=1
           MMx    REPCHAR (:        )
         diffed table   
                diff,   diff    ,   
         p->table_len   len
        write_end     
        read_next_chunk   0     (            )
        101..104      data table codes
-context-based char encoding
  separate coder table after \0 or after \0..\31
+diffing tables
-repboth, repchar1..3
-split caching hash into two parts - pointers and data
  +cyclic hash for large N
+ChangePair in MFN
  -ChangePair for len1-len2>1
           ,      
  -  ,     (   CMF)
block-static arithmetic coder - may improve compression by 1-2%
? caching MF  -l2
+ 5/6-byte main hash for highest modes (-7 and up)
hash3+lazy -    ,     3-   ?
        p+len<bufend
    p+len<=bufend   compress0()
    -1/-2/-3?      
rolz 1+2+3+4
minor thoughts:
  small outbuf for -5 and higher modes
  increase HUFBLOCKSIZE for -2/-3  (100k - -0.2sec)

text files -5/-6: disable 2/3-byte searching, repchar and use encode(..., MINLEN=4), switch to hufcoder(?)
hufcoder: disable REPDIST, +fast qsort<>
huf&ari: EOB, check for text-like stats, switch into text mode

use only one bit for flag in bytecoder
bitcoder: 30-bit length encoding - make it a part of 8-bit encoding
huf/ari - improve "first block" encoding, adaptation (currently, up to 1/64 of codespace is wasted),
  +EOB code
?   ,   chunks, storing  
    header = 1 byte flags + 3 bytes len
  disttables   len
-1,-2,-3?: +no MM, no REP*
huf/ari:  cnt++  cnt+=10 -     (   ,   ; ,     3-  )
ST4/BWT sorting for exhaustive string searching

 tor:5
  - lazy  ()
     by Lasse Reinhold (. )
  - MM tables by rep* codes
   huf    
   :
      2/3-byte matches
     huf c    
       repchar/repdist/repboth
      MM tables

/  tor:7-12
  +     -u1
  +2/3hash:  ,   
  +      >=6/7,    . 
    0/' '  
  check matches at REP_DIST first (should improve compression for binary files)

http://encode.ru/threads/848-LZ77-speed-optimization-2-mem-accesses-per-quot-round-quot by Lasse Reinhold
    Nice, I tried almos the same thing. Of course caching byte 3...6 (and 1?) is mostly an advantage when you want to
    find the longest match out of N possibe because you don&#039;t save the match verification of byte 0..2.

    For finding best match out of N possible (N being 8 in this sample code), I once experimented with caching byte
    0...7 on x64 and looped trough them like:

    long long diff_best = 0, best_i = 0;
    for(i = 1; i < 8; i++)
    {
    long long diff = cache[hash][i] ^ *ptr_input;
    if (diff & -diff > diff_best)
    {
    best_i = i;
    best_diff = diff;
    }
    }

    It utilizes that x & -x returns a word where only the lowest bit in x is set (see http://www.jjj.de/bitwizardry/
    for more code snippets) and it&#039;s a good alternative to using shr/shb bit scan instructions of ARM, x86, x64,
    etc, which unfortunatly isn&#039;t standard in C.

    I just got a ~10% speedup compared to the more naive method of just comparing byte N of *ptr_>input with byte N of
    cache[hash][i] where N is the length of the best match so far, excluding worse matches immediately. I tough speedup
    would be greater and it&#039;s probably worth looking into again.

    "only lowest bit is set" should have been "only lowest set bit is set"


+-h1mb in cmdline
+-z/-d options, by default auto depending on file extension
+-h1m -9 == -9 -h1m (   ,    )
+-odir/ -odir\ -od:
+64-bit insize/outsize
+-b128k, m.hashsize  hashlog, print block/hashsize in help with k/m suffix
+CHECK mallocs
+dir_exists=file_exists(dir\.) || end_with(:/\)
+progress indicator in console title
-t, -f force overwrite, -k keep src files, stdin->stdout by default
make non-inline as much functions as possible (optimize .exe size): +MatchFinder.cpp +LZ77_Coder.cpp
****Tornado 0.2 compressing VC, 41243 kb     --noheader option disables this
****-1: 16kb hash1...: done 5%
****-1: 16kb hash1...: 17876 kb (12.7%), 23.333 sec, 88.6 mb/s
.tor signature, version, flags, crc
?       chunk   storing    ( huf/ari-table)
?     (     , 200-300 kb  all)
+print predefined methods definitions in help screen
-mem      -1  -9?  -bench    
tor_compress:    ==buffer      ,   0  :)



shift buffer by 1/8, 1/16... for large -l
-h512m:64, -ah512m:64, -h -ah -b<128m
hufblock=50.000 in -3 & for texts/compressed
no rep codes in -3  (also useful for -2 -c3)

len7*2: add accept_match check in first cycle
multithreading (support multiple blocks in decoder)
optimal parsing
split cycled caching hash into two parts - pointers and data (probably useful only for optimal parsing because there is no update() in this case)
-t2 full delta filter
-6 -> switch to CCMF<4>	?
MFN<MINLEN,MAXLEN> with checks for dist<48k/... and exit when len>=MAXLEN
maxdist for len=8..9 in accept_match() - may improve compression for 256mb-1gb dictionaries
chunked hash (15 elements + pointer to the next chunk)
-use prevlen to skip checking useless matches (with len<=prevlen)
-if len>32 then lazy_search_row/=4
+match_writer that dynamically uses byte/bit/huf/aricoder
+kadach huffman   (5000/3)

1. tor -5/-6:    p+1,  -  p[0,4,5,6],
                  p  p+1,
                  -    p   48
2.    -     N+4   
          p+4 ( p+1..p+3).      :)

 lazy parsing     
lzma:     p  p+1,   .    -    p ( 48)
buffer-to-buffer decompression, including the PROGRESS callback
^Break - / 
hash4+hash5 -   4- ,     mf5     changepair  ..
?    matchfinder    (4..7)
?LazyMatching<Hash3..> -> Hash3<LazyMatching..>


bugs?
1. UINT len1 = mymin(MINLEN-1, 4); -   ,   4        4   ,  shift()   buf+1,      
2.  MAX_HASHED_BYTES   ,      p<=bufend       12     
2a. accept_match -  p<=bufend  p+len<=bufend
2b. for (; p+len1<bufend && val32equ(p+len1, q1+len1); len1+=4);    p+len1+4<=bufend
+3. files are opened in write-sharing mode!
4. 1<<lb(m.buffer*8)  .  -    hash_row_width != 2^n;        ,
            c_tornado -      
5. r.filesize = -1 -    get_flen     ( linux/win)?    fazip/srep

Optimal parsing: 
+ multiple matches
+ don't restrict 2/3/4-byte matches to small distances
+ REP* codes - either check already found matches against prevdist0..3 or just compare data at prevdist positions. struct PRICES{price, len, dist, prevdist0..3}
+   len  repdist
+ CachingMatchFinder<5..7> support
+ chash -  HashShift  l!=2^n        -5/-6
- 3gb/6gb dictionary and hash (Tornado LZ stream format doesn't support dictionaries > 1GB)
- REPCHAR (  ,   )
-    (p,len)      (p,len-i),      (p+i,len-i)   (p+i,len-j) where j<=i
    p+1 - 
-             silence
* replace 2/3-byte match with 3/4+ byte one if dist is smaller
* suggest - <  <=      (      ,     REPCHAR..)
*  Rescale() -          
*     .    (    lastp-1024byte,           1024 )
       .    1024     
              lzma

Optimal parsing: 
-  Rescale()     842   huf/ari .   evaluate_position      
- dcode = find_dcode(dist);  for(len=...)  price (dcode,len) = prices_arr[dcode][lcode(len)]
+    prevlen   check_match_len()  evaluate_repdist()   
+  / prevdist       
- Evaluate REPDIST-based matches: REPDIST_CODES=1:  100 /    1%   (0.1%  )
      -rd1          REPDIST2..4 (  Rescale()   start_block())
- len>=FastBytes  =>     optimum- (        LZMA)
-   exhash  [c]chash
+ prefetch()  CachingMatchFinder
+ -s1 => 64kb hash3 + 4kb hash2
- huffman (0.5-1%    100m     3-5%)
-   find_all_matches     >fb
-   len->price   repdists;       optimum- ( 1-2%   enwik8)
-  evaluate_position()    EvalBytes ,   /repmatch: len=(match_len-EvalBytes,match_len]
   enwik8 EvalBytes=3: -1%  +10% 
* -l32    , -l8   (   )
* multithreading
*  x[0].prevdist[]   optimum-  
*         len
*   len/dist,         max_len     .
           ,     
*       -     ,     " "?     
     -       .         
      ,     (        )
* BitCachingMatchFinder -  HT4,       
*    CachingMatchFinder::find_all_matches

tor.exe m:\100m -10 -x24 -b6m && tor.exe m:\100m.tor -om:\1 && (fc /b m:\1 m:\100m |head)
C_Tornado:
       main.cpp
    MINLEN>4  ah/al==0
4x4:b256m:t1:i0:tor:8m  : 256mb > 8mb
