wok rev 25647

Backout salvador 10% speedup: crashes with large files
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri Jan 26 12:15:51 2024 +0000 (10 months ago)
parents eaa4b9eff943
children 8ed39abf4bbb
files emu2/receipt salvador/receipt salvador/stuff/shrink.u
line diff
     1.1 --- a/emu2/receipt	Sun Jan 21 10:02:07 2024 +0000
     1.2 +++ b/emu2/receipt	Fri Jan 26 12:15:51 2024 +0000
     1.3 @@ -24,6 +24,7 @@
     1.4  compile_rules()
     1.5  {
     1.6  	cp $stuff/* src
     1.7 +	sed -i '/HALT instruction/{N;s|.*|/*& */|}' src/cpu.c
     1.8  	mkdir obj
     1.9  	make CC=gcc-83 DESTDIR=$DESTDIR install
    1.10  }
    1.11 @@ -35,3 +36,28 @@
    1.12  	cp $src/README.md $install/usr/doc
    1.13  	cp -a $install/usr/bin $fs/usr
    1.14  }
    1.15 +
    1.16 +# Post install command for Tazpkg.
    1.17 +post_install()
    1.18 +{
    1.19 +	fmt="binfmt_misc"
    1.20 +	proc="/proc/sys/fs/binfmt_misc"
    1.21 +	exe=":EMU2:E::exe::/usr/bin/emu2:"
    1.22 +	com=":EMU2:E::com::/usr/bin/emu2:"
    1.23 +	cat > /tmp/runcom$$ <<EOT
    1.24 +[ ! -e $proc/register ] && modprobe $fmt && mount -t $fmt $fmt $proc
    1.25 +echo "$exe" >$proc/register
    1.26 +echo "$com" >$proc/register
    1.27 +EOT
    1.28 +	rc="$1/etc/init.d/local.sh"
    1.29 +	grep -q "$com" $rc || cat /tmp/runcom$$ >> $rc
    1.30 +	[ -n "$1" ] || . /tmp/runcom$$
    1.31 +	rm -f /tmp/runcom$$
    1.32 +}
    1.33 +
    1.34 +# Pre remove command for Tazpkg.
    1.35 +pre_remove()
    1.36 +{
    1.37 +	echo -1 > /proc/sys/fs/binfmt_misc/EMU2
    1.38 +	sed -i '/binfmt_misc/{NN;/EMU2:E::com/d}' "$1/etc/init.d/local.sh"
    1.39 +}
     2.1 --- a/salvador/receipt	Sun Jan 21 10:02:07 2024 +0000
     2.2 +++ b/salvador/receipt	Fri Jan 26 12:15:51 2024 +0000
     2.3 @@ -23,7 +23,6 @@
     2.4  {
     2.5  	sed -i 's|^CC=.*$|CC=gcc|;s|^CFLAGS=|&-std=gnu99 |' \
     2.6  		Makefile
     2.7 -	patch -p0 < $stuff/shrink.u
     2.8  	make
     2.9  }
    2.10  
     3.1 --- a/salvador/stuff/shrink.u	Sun Jan 21 10:02:07 2024 +0000
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,102 +0,0 @@
     3.4 ---- src/shrink.c
     3.5 -+++ src/shrink.c
     3.6 -@@ -41,7 +41,9 @@
     3.7 - #define OFFSET_COST(__offset)    (((__offset) <= 128) ? 8 : (7 + salvador_get_elias_size((((__offset) - 1) >> 7) + 1)))
     3.8 - 
     3.9 - /** Costs, per length */
    3.10 --static const char salvador_cost_for_len[8192] = {
    3.11 -+static char salvador_cost_for_len[MAX_OFFSET];
    3.12 -+
    3.13 -+/**
    3.14 -    0, 2, 4, 4, 6, 6, 6, 6, 8, 8, 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
    3.15 -    18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
    3.16 -    20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
    3.17 -@@ -74,7 +76,8 @@
    3.18 -    26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
    3.19 -    26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
    3.20 -    26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
    3.21 --};
    3.22 -+   ...
    3.23 -+ */
    3.24 - 
    3.25 - /**
    3.26 -  * Get the number of bits required to encode a gamma value
    3.27 -@@ -84,29 +87,7 @@
    3.28 -  * @return number of bits required for encoding
    3.29 -  */
    3.30 - static int salvador_get_elias_size(const int nValue) {
    3.31 --   if (nValue >= 0 && nValue < 8192) {
    3.32 --      return salvador_cost_for_len[nValue] - TOKEN_SIZE;
    3.33 --   }
    3.34 --   else {
    3.35 --      int i = nValue;
    3.36 --      int nBits = 0;
    3.37 --
    3.38 --      i |= (i >> 1);
    3.39 --      i |= (i >> 2);
    3.40 --      i |= (i >> 4);
    3.41 --      i |= (i >> 8);
    3.42 --      i |= (i >> 16);
    3.43 --      i = (i - (i >> 1));
    3.44 --
    3.45 --      while ((i >>= 1) > 0) {
    3.46 --         nBits++;
    3.47 --         nBits++;
    3.48 --      }
    3.49 --
    3.50 --      nBits++;
    3.51 --
    3.52 --      return nBits;
    3.53 --   }
    3.54 -+   return salvador_cost_for_len[nValue] - TOKEN_SIZE;
    3.55 - }
    3.56 - 
    3.57 - /**
    3.58 -@@ -317,10 +298,7 @@
    3.59 -  * @return number of extra bits required
    3.60 -  */
    3.61 - static inline int salvador_get_literals_varlen_size(const int nLength) {
    3.62 --   if (nLength >= 0 && nLength < 8192)
    3.63 --      return salvador_cost_for_len[nLength];
    3.64 --   else
    3.65 --      return TOKEN_SIZE + salvador_get_elias_size(nLength);
    3.66 -+   return salvador_cost_for_len[nLength];
    3.67 - }
    3.68 - 
    3.69 - /**
    3.70 -@@ -642,7 +620,7 @@
    3.71 - 
    3.72 -                for (k = nStartingMatchLen; k <= nMatchLen; k++) {
    3.73 -                   salvador_arrival* pDestSlots = &cur_arrival[k * nMaxArrivalsPerPosition];
    3.74 --                  const int nMatchLenCost = (k < 8192) ? salvador_cost_for_len[k - 1] : (salvador_get_match_varlen_size_norep(k) + TOKEN_SIZE /* token */);
    3.75 -+                  const int nMatchLenCost = salvador_cost_for_len[k - 1];
    3.76 -                   const int nCodingChoiceCost = nMatchLenCost + nNoRepmatchOffsetCost;
    3.77 - 
    3.78 -                   if (nCodingChoiceCost < pDestSlots[nArrivalsPerPosition - 2].cost ||
    3.79 -@@ -716,7 +694,7 @@
    3.80 -             }
    3.81 - 
    3.82 -             for (k = nStartingMatchLen; k <= (nOverallMaxRepLen < nMatchLen ? nOverallMaxRepLen : nMatchLen); k++) {
    3.83 --               const int nMatchLenCost = (k < 8192) ? salvador_cost_for_len[k] : (salvador_get_match_varlen_size_rep(k) + TOKEN_SIZE /* token */);
    3.84 -+               const int nMatchLenCost = salvador_cost_for_len[k];
    3.85 -                salvador_arrival* pDestSlots = &cur_arrival[k * nMaxArrivalsPerPosition];
    3.86 -                int nCurRepMatchArrival;
    3.87 - 
    3.88 -@@ -1789,6 +1767,17 @@
    3.89 - static int salvador_compressor_init(salvador_compressor *pCompressor, const int nBlockSize, const int nMaxWindowSize, const size_t nMaxOffset, const int nMaxArrivals, const int nFlags) {
    3.90 -    int nResult;
    3.91 - 
    3.92 -+   if (salvador_cost_for_len[1] == 0) {
    3.93 -+      int i, j, k;
    3.94 -+
    3.95 -+      for (i = 0, j = 0, k = 1; i < MAX_OFFSET; i++) {
    3.96 -+         if (k <= i) {
    3.97 -+            j = j + 2;
    3.98 -+            k = k + k;
    3.99 -+         }
   3.100 -+         salvador_cost_for_len[i] = j;
   3.101 -+      }
   3.102 -+   }
   3.103 -    nResult = divsufsort_init(&pCompressor->divsufsort_context);
   3.104 -    pCompressor->intervals = NULL;
   3.105 -    pCompressor->pos_data = NULL;