Skip to content

Commit

Permalink
Merge pull request #667 from easyaspi314/sizeopt
Browse files Browse the repository at this point in the history
Introduce XXH_SIZE_OPT and XXH_NO_STREAM
  • Loading branch information
Cyan4973 committed Jan 6, 2022
2 parents 83b2235 + 4690bbe commit b1a61df
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 27 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -139,12 +139,23 @@ jobs:
run: |
CFLAGS="-Wall -Wextra -Werror" make DISPATCH=1 clean default
- name: XXH_SIZE_OPT == 2
if: always()
run: |
CFLAGS="-Os -DXXH_SIZE_OPT=2 -Wall -Wextra -Werror" make clean xxhsum
- name: noxxh3test
if: always()
run: |
# check library can be compiled with XXH_NO_XXH3, resulting in no XXH3_* symbol
make clean noxxh3test
- name: nostreamtest
if: always()
run: |
# check library can be compiled with XXH_NO_STREAM, resulting in no streaming symbols
make clean noxxh3test
- name: make avx512f
if: ${{ matrix.avx512 == 'true' }}
run: |
Expand Down
10 changes: 10 additions & 0 deletions Makefile
Expand Up @@ -342,6 +342,16 @@ noxxh3test: xxhash.c
$(NM) $(OFILE) | $(GREP) XXH3_ ; test $$? -eq 1
$(RM) $(OFILE)

.PHONY: nostreamtest
nostreamtest: CPPFLAGS += -DXXH_NO_STREAM
nostreamtest: CFLAGS += -Werror -pedantic -Wno-long-long # XXH64 requires long long support
nostreamtest: OFILE = xxh_nostream.o
nostreamtest: xxhash.c
@echo ---- test compilation without streaming ----
$(CC) $(FLAGS) -c $^ -o $(OFILE)
$(NM) $(OFILE) | $(GREP) update ; test $$? -eq 1
$(RM) $(OFILE)

.PHONY: nostdlibtest
nostdlibtest: CPPFLAGS += -DXXH_NO_STDLIB
nostdlibtest: CFLAGS += -Werror -pedantic -Wno-long-long # XXH64 requires long long support
Expand Down
4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -113,6 +113,10 @@ The following macros can be set at compilation time to modify libxxhash's behavi
- `XXH_VECTOR` : manually select a vector instruction set (default: auto-selected at compilation time). Available instruction sets are `XXH_SCALAR`, `XXH_SSE2`, `XXH_AVX2`, `XXH_AVX512`, `XXH_NEON` and `XXH_VSX`. Compiler may require additional flags to ensure proper support (for example, `gcc` on linux will require `-mavx2` for AVX2, and `-mavx512f` for AVX512).
- `XXH_NO_PREFETCH` : disable prefetching. Some platforms or situations may perform better without prefetching. XXH3 only.
- `XXH_PREFETCH_DIST` : select prefetching distance. For close-to-metal adaptation to specific hardware platforms. XXH3 only.
- `XXH_NO_STREAM`: Disables the streaming API, limiting it to single shot variants only.
- `XXH_SIZE_OPT`: `0`: default, optimize for speed
`1`: default for `-Os` and `-Oz`: disables some speed hacks for size optimization
`2`: makes code as small as possible, performance may cry
- `XXH_NO_INLINE_HINTS`: By default, xxHash uses `__attribute__((always_inline))` and `__forceinline` to improve performance at the cost of code size.
Defining this macro to 1 will mark all internal functions as `static`, allowing the compiler to decide whether to inline a function or not.
This is very useful when optimizing for smallest binary size,
Expand Down

0 comments on commit b1a61df

Please sign in to comment.