Files
wuffs/release/c
Nigel Tao 8d9d6c1292 Performance mystery: load-bearing "no-op continue"
There is no semantic difference in this commit. There's no further code
after the if-else chain in the loop body. Nonetheless, adding a "no-op
continue" impacts performance: bad for clang and good for gcc.

Profiling suggests we spend less than 5% overall in
wuffs_jpeg__decoder__fill_bitstream.

name                                             old speed     new speed     delta

wuffs_jpeg_decode_19k_8bpp/clang11               241MB/s ± 0%  229MB/s ± 0%  -5.02%  (p=0.008 n=5+5)
wuffs_jpeg_decode_30k_24bpp_progressive/clang11  213MB/s ± 0%  205MB/s ± 0%  -4.13%  (p=0.008 n=5+5)
wuffs_jpeg_decode_30k_24bpp_sequential/clang11   386MB/s ± 0%  375MB/s ± 0%  -2.88%  (p=0.008 n=5+5)
wuffs_jpeg_decode_77k_24bpp/clang11              341MB/s ± 0%  326MB/s ± 0%  -4.58%  (p=0.008 n=5+5)
wuffs_jpeg_decode_552k_24bpp_420/clang11         356MB/s ± 0%  339MB/s ± 0%  -4.90%  (p=0.008 n=5+5)
wuffs_jpeg_decode_552k_24bpp_444/clang11         484MB/s ± 0%  475MB/s ± 0%  -1.96%  (p=0.008 n=5+5)
wuffs_jpeg_decode_4002k_24bpp/clang11            364MB/s ± 0%  343MB/s ± 0%  -5.83%  (p=0.008 n=5+5)

wuffs_jpeg_decode_19k_8bpp/gcc10                 234MB/s ± 0%  245MB/s ± 0%  +4.68%  (p=0.008 n=5+5)
wuffs_jpeg_decode_30k_24bpp_progressive/gcc10    245MB/s ± 0%  254MB/s ± 0%  +3.35%  (p=0.008 n=5+5)
wuffs_jpeg_decode_30k_24bpp_sequential/gcc10     500MB/s ± 0%  514MB/s ± 0%  +2.81%  (p=0.008 n=5+5)
wuffs_jpeg_decode_77k_24bpp/gcc10                417MB/s ± 0%  434MB/s ± 0%  +4.18%  (p=0.008 n=5+5)
wuffs_jpeg_decode_552k_24bpp_420/gcc10           442MB/s ± 0%  459MB/s ± 0%  +3.76%  (p=0.008 n=5+5)
wuffs_jpeg_decode_552k_24bpp_444/gcc10           477MB/s ± 0%  486MB/s ± 0%  +1.99%  (p=0.008 n=5+5)
wuffs_jpeg_decode_4002k_24bpp/gcc10              450MB/s ± 0%  467MB/s ± 0%  +3.70%  (p=0.008 n=5+5)

It is a mystery why this happens. Note though that the "continue" in the
Wuffs code becomes a "goto" in the generated C code, because (in the
general case) Wuffs has "labeled continue/break", which can jump out of
a not-inner-most loop, and C99 does not. Wuffs' "generate C code" thus
uses a C "goto". A follow-up commit may try a C "continue" instead.

To reproduce:

----
$ git clone https://github.com/google/wuffs.git
$ cd wuffs
$ gcc --version | head -n 1
gcc (Debian 10.2.1-6) 10.2.1 20210110

$ # Check out this commit.
$ git checkout --quiet THE_HASH_OF_THIS_COMMIT
$ gcc -O3 -Wall -std=c99 test/c/std/jpeg.c -DWUFFS_MIMIC -ljpeg
$ ./a.out -bench -focus=wuffs_jpeg_decode_77k_24bpp | grep MB/s
Benchmarkwuffs_jpeg_decode_77k_24bpp/gcc10	    3000	  176988 ns/op	     433.927 MB/s
Benchmarkwuffs_jpeg_decode_77k_24bpp/gcc10	    3000	  176849 ns/op	     434.268 MB/s
Benchmarkwuffs_jpeg_decode_77k_24bpp/gcc10	    3000	  176800 ns/op	     434.389 MB/s
Benchmarkwuffs_jpeg_decode_77k_24bpp/gcc10	    3000	  176844 ns/op	     434.279 MB/s
Benchmarkwuffs_jpeg_decode_77k_24bpp/gcc10	    3000	  176869 ns/op	     434.218 MB/s

$ # Check out the parent commit.
$ git checkout --quiet THE_HASH_OF_THIS_COMMIT^
$ gcc -O3 -Wall -std=c99 test/c/std/jpeg.c -DWUFFS_MIMIC -ljpeg
$ ./a.out -bench -focus=wuffs_jpeg_decode_77k_24bpp | grep MB/s
Benchmarkwuffs_jpeg_decode_77k_24bpp/gcc10	    3000	  183848 ns/op	     417.734 MB/s
Benchmarkwuffs_jpeg_decode_77k_24bpp/gcc10	    3000	  183870 ns/op	     417.684 MB/s
Benchmarkwuffs_jpeg_decode_77k_24bpp/gcc10	    3000	  183833 ns/op	     417.770 MB/s
Benchmarkwuffs_jpeg_decode_77k_24bpp/gcc10	    3000	  183873 ns/op	     417.679 MB/s
Benchmarkwuffs_jpeg_decode_77k_24bpp/gcc10	    3000	  183843 ns/op	     417.746 MB/s
----
2023-06-23 17:02:14 +10:00
..
2019-12-20 00:52:23 +11:00
2023-04-08 14:57:52 +10:00

Releases (in the C Programming Language)

Wuffs the Library ships as a "single file C library", also known as a "header file library".

To use that library in your C/C++ project, you just need to copy one file from this directory, or otherwise integrate that one file into your build system. Typically, pick the latest stable version (but not the unsupported snapshot), with a filename like wuffs-vMAJOR.MINOR.c for version MAJOR.MINOR.

To use that single file as a "foo.c"-like implementation, instead of a "foo.h"-like header, #define WUFFS_IMPLEMENTATION before #include'ing or compiling it.

Latest Stable Version

Version 0.2 (December 2019) is the latest stable version. Stable means that its API won't change any further, but being a "version 0.x" means that:

  • It will not have long term support.
  • Newer versions make no promises about compatibility.

Mirror

Wuffs' canonical repository is located at github.com/google/wuffs. If you just want to use Wuffs-the-library in its C form (instead of modifying its Wuffs form or otherwise needing Wuffs-the-language tools), a mirror of just the release/c directory is located at github.com/google/wuffs-mirror-release-c. By excluding everything else, the mirror is much smaller than and changes much less frequently than the canonical repository.