zstd/lib/common
Nick Terrell 8e43f53c93 [lazy] Use switch instead of indirect function calls.
Use a switch statement to select the search function instead of an
indirect function call. This results in a sizable performance win.

This PR is a modification of the approach taken in PR #2828.
When I measured performance for that commit, it was neutral.
However, I now see a performance regression on gcc, but still
neutral on clang. I'm measuring on the same platform, but with
newer compilers. The new approach beats both the current dev
branch and the baseline before PR #2828 was merged.

This PR is necessary for Issue #3275, to update zstd in the kernel.
Without this PR there is a large regression in greedy - btlazy2
compression speed. With this PR it is about neutral.

gcc version: 12.2.0
clang version: 14.0.6
dataset: silesia.tar

| Compiler | Level | Dev Speed (MB/s) | PR Speed (MB/s) | Delta  |
|----------|-------|------------------|-----------------|--------|
| gcc      |     5 |            102.6 |           113.7 | +10.8% |
| gcc      |     7 |             66.6 |            74.8 | +12.3% |
| gcc      |     9 |             51.5 |            58.9 | +14.3% |
| gcc      |    13 |             14.3 |            14.3 |  +0.0% |
| clang    |     5 |            108.1 |           114.8 |  +6.2% |
| clang    |     7 |             68.5 |            72.3 |  +5.5% |
| clang    |     9 |             53.2 |            56.2 |  +5.6% |
| clang    |    13 |             14.3 |            14.7 |  +2.8% |

The binary size stays just about the same for clang and gcc, measured
using the `size` command:

| Compiler | Branch | Text    | Data | BSS | Total   |
|----------|--------|---------|------|-----|---------|
| gcc      | dev    | 1127950 | 3312 | 280 | 1131542 |
| gcc      | PR     | 1123422 | 2512 | 280 | 1126214 |
| clang    | dev    | 1046254 | 3256 | 216 | 1049726 |
| clang    | PR     | 1048198 | 2296 | 216 | 1050710 |
2022-10-21 15:27:26 -07:00
..
bitstream.h Merge pull request #2800 from animalize/fix_c89 2021-10-18 14:32:04 -07:00
compiler.h [lazy] Use switch instead of indirect function calls. 2022-10-21 15:27:26 -07:00
cpu.h [copyright][license] Switch to yearless copyright and some cleanup in the linux-kernel files 2021-03-30 10:30:43 -07:00
debug.c [copyright][license] Switch to yearless copyright and some cleanup in the linux-kernel files 2021-03-30 10:30:43 -07:00
debug.h [copyright][license] Switch to yearless copyright and some cleanup in the linux-kernel files 2021-03-30 10:30:43 -07:00
entropy_common.c [bmi2] Add lzcnt and bmi target attributes 2021-11-30 17:54:56 -08:00
error_private.c [copyright][license] Switch to yearless copyright and some cleanup in the linux-kernel files 2021-03-30 10:30:43 -07:00
error_private.h Huffman ASM 2021-09-20 14:46:43 -07:00
fse.h Add 8 bytes to FSE workspace 2021-09-01 15:56:33 -04:00
fse_decompress.c [bmi2] Add lzcnt and bmi target attributes 2021-11-30 17:54:56 -08:00
huf.h Huffman ASM 2021-09-20 14:46:43 -07:00
mem.h Add typedefs for 8bit (un)signed 2021-12-14 23:47:57 +01:00
pool.c fixed backup prototype for POOL_sizeof() 2021-12-30 14:33:21 -08:00
pool.h POOL_sizeof() only needs a const read-only reference 2021-12-30 14:08:51 -08:00
portability_macros.h x86-64: Hide internal assembly functions 2022-01-11 10:12:24 -08:00
threading.c ZSTD_ prefix mem{cpy,move,set},malloc,calloc,free 2020-08-26 12:26:03 -07:00
threading.h Fix copyright and license lines 2020-03-26 17:02:06 -07:00
xxhash.c altered copyright title 2021-12-08 13:18:41 -08:00
xxhash.h remove offending static assert lines 2021-12-08 15:05:17 -08:00
zstd_common.c [copyright][license] Switch to yearless copyright and some cleanup in the linux-kernel files 2021-03-30 10:30:43 -07:00
zstd_deps.h [copyright][license] Switch to yearless copyright and some cleanup in the linux-kernel files 2021-03-30 10:30:43 -07:00
zstd_internal.h regroup all mentions of ZSTD_REP_MOVE within zstd_compress_internal.h 2021-12-28 13:47:57 -08:00
zstd_trace.h [trace] Refine the ZSTD_HAVE_WEAK_SYMBOLS detection 2021-05-18 20:22:36 -07:00